17 January 2010

rh lattice tesselation01//////////////////////////////////////////

Just another code done some time ago on lattice tesselation. The code :
.divides a surface in U&V points defined by the user
.draws a matrix of points that follows the simple pattern of two splines
.creates circles ( number of circles are defined by the user) perpendicular to a curve
.creates a loft surface trough the circles



here the code:
Option Explicit
'Script written by Davide del Giudice
'Script copyrighted by www.madeincalifornia.blogspot.com
'Script version venerdì 28 agosto 2009 16.07.36
'Original code SUPERMANOEUVRE


MsgBox " LATTICE TESSELATION/// Script written by Davide del Giudice/// www.madeincalifornia.blogspot.com "

Call DivideSurface()
Sub DivideSurface()
'--------------------
'DEFINE INPUT
Dim strSrf:strSrf= rhino.getobject("Select surface",8,16)
If isNull(strsrf) Then Exit Sub
Dim intUint: intUint= rhino.getInteger(" U divisions", 20,4,100)
Dim intVint:intVint= rhino.GetInteger(" V divisions", 20,4,100)

Dim IntNPts: intNPts = Rhino.GetInteger("how many samples?", 10, 2, 100) 'chiedo il dimensionamento

If isNull(intUint) Then Exit Sub
If isNull(intVint) Then Exit Sub
If isNull(IntNPts) Then Exit Sub



'-----------
'SCRIPT BODY
rhino.print" script started now, enjoy!"
'-----------
'Get U values
Dim arrSrfDomU : arrSrfDomU= Rhino.SurfaceDomain(strSrf,0)
Dim uMin: uMin= arrsrfDomU (0)
Dim uMax:uMax = arrsrfDomU (1)
Dim uStep:uStep=(uMax-uMin)/intUint

'-----------------
'Get V values
Dim arrSrfDomV : arrSrfDomV= Rhino.SurfaceDomain(strSrf,1)
Dim vMin: vMin= arrsrfDomV (0)
Dim vMax:vMax = arrsrfDomV (1)
Dim vStep:vStep=(vMax-vMin)/intVint


'------------------
'crate panels
Dim i,j
Dim arrpt01,arrpt02,arrpt03,arrpt04,arrpt05,arrpt06,arrpt07,arrpt08,arrpt09,arrpt10,arrpt11,arrpt12,arrpt13,arrpt14,arrcnrpts1,arrcnrpts2,arrpoints,strline1,strline2


For i=uMin To uMax-uStep Step 6*uStep

For j= vMin To vMax-vStep Step 2*vStep

'first panel

arrpt01=rhino.EvaluateSurface(strSrf,array(i,j))
arrpt02=rhino.EvaluateSurface(strsrf,array(i+ustep,j))
arrpt03=rhino.evaluateSurface(strsrf,array(i+2*uStep,j+vstep))
arrpt04=rhino.evaluateSurface(strsrf,array(i+3*uStep,j+vstep))
arrpt09=rhino.evaluateSurface(strsrf,array(i+4*uStep,j+vstep))
arrpt10=rhino.evaluateSurface(strsrf,array(i+5*uStep,j))
arrpt11=rhino.evaluateSurface(strsrf,array(i+6*uStep,j))



'second panel

arrpt05=rhino.EvaluateSurface(strSrf,array(i,j+2*vstep))
arrpt06=rhino.EvaluateSurface(strSrf,array(i+ustep,j+2*vstep))
arrpt07=rhino.EvaluateSurface(strSrf,array(i+2*ustep,j+vstep))
arrpt08=rhino.EvaluateSurface(strSrf,array(i+3*ustep,j+vstep))
arrpt12=rhino.EvaluateSurface(strSrf,array(i+4*ustep,j+vstep))
arrpt13=rhino.EvaluateSurface(strSrf,array(i+5*ustep,j+2*vstep))
arrpt14=rhino.EvaluateSurface(strSrf,array(i+6*ustep,j+2*vstep))

'point in an array

arrcnrpts1= array(arrpt01,arrpt02,arrpt03,arrpt04,arrpt09,arrpt10,arrpt11)
arrcnrpts2= array(arrpt05,arrpt06,arrpt07,arrpt08,arrpt12,arrpt13,arrpt14)

Rhino.AddPoints (arrcnrpts1)
rhino.AddPoints(arrcnrpts2)

strline1= rhino.addcurve (arrcnrpts1)
strline2= rhino.addcurve(arrcnrpts2)

Dim arrDom: arrDom = Rhino.CurveDomain(strline1)
Dim dblparam,dblStep
ReDim arrCirc1(intNpts),arrCirc2(intNpts)
Dim k,arrplane1,dblradius,arrplane2

dblStep = (arrDom(1)-arrDom(0))/(intNPts)


For k=0 To intNPts 'Step 0.1


dblParam = arrDom(0) + k*dblStep

arrPlane1 = Rhino.CurvePerpFrame(strline1, dblParam)
arrPlane2 = Rhino.CurvePerpFrame(strline2, dblParam)

arrCirc1(k)= Rhino.AddCircle(arrPlane1, .05)
arrCirc2(k)= Rhino.AddCircle(arrPlane2, .05)
Next

Call Rhino.AddLoftSrf (arrcirc1)
Rhino.AddLoftSrf (arrcirc2)


Next 'end j loop
Next 'endi loop

rhino.HideObject strSrf

rhino.print " script end"

End Sub




1 commenti:

said...

要像鐵鎚和釘子一樣,永遠向著定點努力。..................................................