EM_curve generator

Option Explicit

Call Main()
Sub Main()

Call Rhino.AddLayer(“Voro3DCurves”, RGB(0, 255, 0))
Rhino.CurrentLayer(“Voro3DCurves”)

Dim aCrvs : aCrvs = Rhino.GetObjects(“Pick Voronoi Cells”, 4)

Dim i,j

For i = 0 To UBound( aCrvs)

Dim x,y,z,d
x = funcRnd(0.9,0)
y = x + funcRnd(0.3,0.1)
‘y = funcRnd(0.9,0)
‘y = x
‘z = funcRnd(1,0.9)
z = 1
d = funcRnd(0.5,0.1)

If Rhino.IsCurveClosed(aCrvs(i)) And Rhino.IsPolyline(aCrvs(i)) Then

Dim aCtrlPts : aCtrlPts = Rhino.PolylineVertices(acrvs(i))
ReDim aPts(UBound(aCtrlPts)+1)
For j = 0 To UBound(aCtrlPts)
Dim aPlane : aPlane = Rhino.WorldXYPlane
Dim vDir : vDir = Rhino.VectorScale(aPlane(3), funcRnd(600,500))
aPts(j) = Rhino.PointAdd(aCtrlPts(j), vDir)
Next
aPts(UBound(aCtrlPts)+1) = aPts(0)

Dim VoroCurve3D : VoroCurve3D = Rhino.AddCurve(aPts)
Dim arrBBox: arrBBox = Rhino.BoundingBox(VoroCurve3D)
Dim arrCntrPt : arrCntrPt = array((((arrBBox(2)(0)) + (arrBBox(0)(0))) / 2)+d, (((arrBBox(2)(1)) + (arrBBox(0)(1))) / 2)+d, (((arrBBox(0)(2)) + (arrBBox(4)(2))) / 2)+d)
Dim ScVoroCurve3D : ScVoroCurve3D = Rhino.ScaleObject(VoroCurve3D,arrCntrPt,array(x,y,z),True)
Call Rhino.ObjectColor(ScVoroCurve3D, RGB(0, 0, 255))

End If
Next

‘Rhino.Command(“_MeshPatch”)
‘Rhino.Command(“_OffsetMesh”)

End Sub
Function funcRnd(max,min)

Randomize
funcRnd = (max-min) * Rnd + min

End Function

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s