Stay in the box (in process)

Call Main()
Sub Main()

Dim strSrf : strSrf = Rhino.GetObject(“closed surface”,16)

Dim arrPtSeed : arrPtSeed = Rhino.GetObject(“Base Point”,1)
arrPtSeed = Rhino.PointCoordinates(arrPtSeed)

Dim n : n = 200 ‘Rhino.GetInteger(“nr of points”, 10)

” SPEED:
Dim bbox : bbox = Rhino.BoundingBox(strSrf)
Dim min : min = -50 ‘Rhino.Distance(bbox(0),bbox(6))/8
Dim max : max = 50’ Rhino.Distance(bbox(0),bbox(6))/4

Dim i, k : k = 1 : i = 0
Dim arrPt
Dim arrPtsCollect()

ReDim Preserve arrPtsCollect(0)
arrPtsCollect(0) = arrPtSeed

‘For i=0 To n-1
Do Until k = n+1

arrPt = array(arrPtSeed(0)+arbitraryValue(min, max),_
arrPtSeed(1) + arbitraryValue(min, max),_
arrPtSeed(2)+ arbitraryValue(min, max))

If Rhino.IsPointInSurface (strSrf, arrPt) then
ReDim Preserve arrPtsCollect(k)
arrPtsCollect(k) = arrPt
Call rhino.AddLine(arrPtsCollect(k-1), arrPtsCollect(k))
k = k + 1
i = 0
Else
i = i + 1
End If

If i = 100 Then Exit Sub

Loop
‘Next
Call rhino.AddPolyline(arrPtsCollect)

End Sub

Function arbitraryValue(min, max)
Randomize
arbitraryValue = Int((max – min + 1) * Rnd + min)
End Function

Stay_in_box

Stay_in_box

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