1204random select

Option Explicit
‘Script written by Macus Chen
‘Script copyrighted by <insert company name>
‘Script version Friday, December 04, 2009 12:04:27 PM

Call Main()
Sub Main()
Dim arrObjects, selPer, arrSuccess(), sCount, i

‘ input
arrObjects = Rhino.GetObjects(“pick objects to randomly select from”, 0)
selPer = Rhino.GetReal(“percentage to select”, 50)

‘ loop through each object
For i = 0 To UBound(arrObjects)

If (Rnd*100) <= selPer Then
‘ add to array
ReDim Preserve arrSuccess(sCount)
arrSuccess(sCount) = arrObjects(i)
sCount = sCount + 1
End If


Rhino.SelectObjects arrSuccess
End Sub

Function bBoxCenter(obj)

Dim bbox
bbox = Rhino.BoundingBox(obj)
bBoxCenter = Array( (bbox(0)(0) + bbox(6)(0))/2, (bbox(0)(1) + bbox(6)(1))/2, (bbox(0)(2) + bbox(6)(2))/2 )

End Function

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s