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
Next
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