2008年11月4日 星期二

Rhino Script Excise04


Option Explicit
'Script written by David Rutten
'Script copyrighted by Robert McNeel & Associates
'This script will compute a bunch of cross-product vector based on a pointcloud
'Script version 2008年11月2日 下午 12:13:07

Call VectorField()
Sub VectorField()
Dim strCloudID
strCloudID = Rhino.GetObject("Input pointcloud", 2, True, True)
If IsNull(strCloudID) Then Exit Sub

Dim arrPoints : arrPoints = Rhino.PointCloudPoints(strCloudID)
Dim ptBase : ptBase = Rhino.GetPoint("Vector field base point")
If IsNull(ptBase) Then Exit Sub

Dim i
For i = 0 To UBound(arrpoints)
Dim vecBase
vecBase = Rhino.VectorCreate(arrPoints(i), ptBase)

Dim vecDir : vecDir = Rhino.VectorCrossProduct(vecBase, Array(0,0,1))

If Not IsNull(vecDir) Then
vecDir = Rhino.VectorUnitize(vecDir)
vecDir = Rhino.VectorScale(vecDir, 2.0)

Call AddVector(vecDir, arrPoints(i))
End If
Next
End Sub

沒有留言: