it's a script with fuction : "isPointInSurfaces(arrStrObject, arrPoint)" "randRange(min, max)" the aim is generate random position points in a certain cage made of several closed polysurfaces
here's the video tutorial:
here's the code: Option Explicit 'Script written by popabczhang 'Script copyrighted by popabczhang 'Script version 2008-12-31 17:34:50
Dim i,j Dim xx:xx=0 Dim yy:yy=1 Dim zz:zz=2
Call happYneWyeaR()
Sub happYneWyeaR() Dim i Dim arrTmpPt(2)
Dim arrPts() i=0 Do While i <= 2999 Randomize arrTmpPt(xx) = randRange(0,700*100)/100 arrTmpPt(yy) = randRange(0,90*100)/100 arrTmpPt(zz) = randRange(0,1*100)/100 If isPointInSurfaces(Rhino.ObjectsByName("cage"),arrTmpPt) Then ReDim Preserve arrPts(i) arrPts(i) = arrTmpPt rhino.AddPoint arrTmpPt rhino.Print "point(" & i & ")"
i = i+1 End If Loop End Sub
Function isPointInSurfaces(arrStrObject, arrPoint) Dim blnTemp:blnTemp = False For i = 0 To UBound(arrStrObject) If Rhino.IsPointInSurface(arrStrObject(i), arrPoint) Then blnTemp = True End If Next isPointInSurfaces = blnTemp End Function
Function randRange(min, max) Randomize randRange = min+rhino.Floor(Rnd*(max-min)) End Function