This script is drawing lines on a surface depending on u and v parameters to pipe a circle along them so that it creates structure that looks like a nest:
Option Explicit
‘If it is working then scripted by Eduardo Mayoral
‘If Not scripted by anyone else
Call Nest()
Sub Nest()
’================================================
’ Selecting and Evaluating Surface
’================================================
Dim strsurface : strsurface = Rhino.GetObject(“Select Surface to Weave”,
Dim ptBase : ptBase = Rhino.GetPoint(“Select starting Point “)
Dim ptEnd : ptEnd = Rhino.GetPoint(“Select ending Point”)
Dim udom, vdom, uparam, vparam, arrpt, i, j, y, udiv, vdiv
udiv = 200
vdiv = 200
ReDim colec2d(udiv, vdiv)
udom = Rhino.SurfaceDomain(strsurface,0)
vdom = Rhino.SurfaceDomain(strsurface,1)
For i = 0 To udiv
For j = 0 To vdiv
uparam = udom(0) + rnd * (udom(1) – udom(0))
vparam = vdom(0) + rnd * (vdom(1) – vdom(0))
arrpt = Rhino.EvaluateSurface(strsurface, array(uparam, vparam))
colec2d(i,j) = arrpt
Next
Next
’================================================
’ Defining Planes and Calling Functions
’================================================
Dim colec, colec2
For j = 0 To vdiv – 1
colec = array (colec2d(0,j), colec2d(udiv,j))
Dim arrplane : arrplane = Rhino.PlaneFromFrame (colec2d(0,j), array(1,0,0), array(0,1,0))
Dim curve: curve = micrv(strsurface, colec)
Call crazypipes(curve, ptBase, ptEnd)
Next
’Call rhino.Deleteobject (strsurface)
End Sub
‘================================================
‘ Function to Interpolate Curves on Surface
‘================================================
Function micrv(strsurface, colec)
Dim curve: curve = Rhino.AddInterpCrvOnSrf (strsurface, colec)
micrv = curve
End Function
‘================================================
‘ Function for piping
‘================================================
Function crazypipes(crv, bs, en)
Dim dom, param, arrpt, i
arrpt = Rhino.DivideCurve(crv, 10, False)
ReDim colecCrv(Ubound(arrpt))
For i = 0 To Ubound(arrpt)
Dim dblParameter: dblParameter = Rhino.CurveClosestPoint (crv, arrpt(i))
Dim plane: plane = Rhino.CurvePerpFrame (crv, dblParameter)
Dim angle: angle = rhino.Angle2(array(bs, en), array(bs, arrpt(i)))
Rhino.print (angle(0))
If angle(0) < 60 Then
colecCrv(i) = Rhino.AddCircle (plane, 0.0001*angle(0))
Else
colecCrv(i) = Rhino.AddCircle(plane, 0.0003*angle(0))
End If
Next
Call Rhino.AddLoftSrf(colecCrv)
End Function
0 responses so far ↓
There are no comments yet...Kick things off by filling out the form below.