January 5, 2009

happY neW yeaR ! - a basic rhino script tutorial - with code & files

hey every body
happy new year to all

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()
Do While i <= 2999

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
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
isPointInSurfaces = blnTemp
End Function

Function randRange(min, max)
randRange = min+rhino.Floor(Rnd*(max-min))
End Function

here's the files ( 3dm & rvb ) :


mario said...

try www.vimeo.com for videos in hd

madhav said...

ya its good