' slope -> points on surface function getdbl(inf,nam,def) dat=rhino.getdocumentdata("cad",nam) if isnull(dat) then dat=def if isnull(inf) then getdbl=dat : exit function val=rhino.getreal(inf&" ?",cdbl(dat)) rhino.setdocumentdata "cad",nam,cstr(val) getdbl=val end function ' interpolation function interp(x0,y0,x1,y1,y) x=x0+(x1-x0)*(y-y0)/(y1-y0) interp=x end function ' from upper and lower point ' -> new up & low points at half (U,V)distance ' 'point' : array (znormal,u,v) function closerpts(su,sina,p0,p1) u=(p0(1)+p1(1))/2 v=(p0(2)+p1(2))/2 nrm=rhino.surfacenormal(su,array(u,v)) if nrm(2)<0 then nrm=rhino.vectorreverse(nrm) midp=array(nrm(2),u,v) if sgn(p0(0)-sina)<>sgn(nrm(2)-sina) then closerpts=array(p0,midp) else closerpts=array(midp,p1) end if end function sub main obs=rhino.getobjects("Surfaces ?",8,,true) an=getdbl("Angle","slope-angle",45) stp=getdbl("Step for points","slope-stp",5) stc=getdbl("Step for checking","slope-stc",1) refcnt=cint(log(stp/stc)/log(2))+1 rhino.print cstr(refcnt)&" refinements" rhino.prompt"Calculating ..." rhino.enableredraw false cnt=0 for each su in obs if rhino.issurface(su) then sina=sin(an/180*rhino.pi) rnu=rhino.surfacedomain(su,0) rnv=rhino.surfacedomain(su,1) iso=rhino.extractisocurve(su,array((rnu(0)+rnu(1))/2,(rnv(0)+rnv(1))/2),2) lu=rhino.curvelength(iso(0)) lv=rhino.curvelength(iso(1)) rhino.deleteobjects iso du=(rnu(1)-rnu(0))/2000 rnu(0)=rnu(0)+du rnu(1)=rnu(1)-du dv=(rnv(1)-rnv(0))/2000 rnv(0)=rnv(0)+dv rnv(1)=rnv(1)-dv nu=cint(lu/stp)+2 nv=cint(lv/stp)+2 du=(rnu(1)-rnu(0))/nu dv=(rnv(1)-rnv(0))/nv dim zn redim zn(nu,nv) for i=0 to nu-1 for j=0 to nv-1 u=rnu(0)+du*(i+0.5) v=rnv(0)+dv*(j+0.5) nrm=rhino.surfacenormal(su,array(u,v)) if nrm(2)<0 then nrm=rhino.vectorreverse(nrm) zn(i,j)=nrm(2) next next for i=1 to nu-1 for j=0 to nv-1 if sgn(zn(i,j)-sina)<>sgn(zn(i-1,j)-sina) then u=rnu(0)+du*(i+0.5) v=rnv(0)+dv*(j+0.5) p0=array(zn(i,j),u,v) u=rnu(0)+du*(i-1+0.5) p1=array(zn(i-1,j),u,v) for k=1 to refcnt ar=closerpts(su,sina,p0,p1) p0=ar(0) p1=ar(1) next u=interp(p0(1),p0(0),p1(1),p1(0),sina) v=p0(2) pt=rhino.evaluatesurface(su,array(u,v)) rhino.addpoint pt cnt=cnt+1 end if next next for i=0 to nu-1 for j=1 to nv-1 if sgn(zn(i,j)-sina)<>sgn(zn(i,j-1)-sina) then u=rnu(0)+du*(i+0.5) v=rnv(0)+dv*(j+0.5) p0=array(zn(i,j),u,v) v=rnv(0)+dv*(j-1+0.5) p1=array(zn(i,j-1),u,v) for k=1 to refcnt ar=closerpts(su,sina,p0,p1) p0=ar(0) p1=ar(1) next v=interp(p0(2),p0(0),p1(2),p1(0),sina) u=p0(1) pt=rhino.evaluatesurface(su,array(u,v)) rhino.addpoint pt cnt=cnt+1 end if next next end if next rhino.unselectallobjects rhino.enableredraw true rhino.print"Added "&cstr(cnt)&" points" end sub main