Tuesday, October 12, 2010

Polyline Network Surface on Rhino


An example of using Rhinoscript for creating a Netwrok Surface in Rhino:

Original Link: Polyline Network Surface

Option Explicit
‘Script written by Howard Jiho Kim
‘Script version Monday, March 10, 2008 12:46:21 PM

Call Main()
Sub Main()

Dim strObject, strObject2, arrObjects
Dim netCrv(100)
Dim i
Dim arrNew
i=0

arrObjects = Rhino.GetObjects(“Pick some curves”, 4)

If IsArray(arrObjects) Then

For Each strObject In arrObjects

If Rhino.IsPolyline(strObject) Then
netCrv(i) = SubDividePolyline(strObject)
Print netCrv(i)
Rhino.SelectObject netCrv(i)
i=i+1
End If

Next

End If

Rhino.Command(“NetworkSrf”)

End Sub

Function SubDividePolyline(strObject)
Dim arrV
arrV = Rhino.PolylineVertices(strObject)
Dim arrSubD() : ReDim arrSubD(2 * UBound(arrV))
Dim i

For i=0 To UBound(arrV)-1

arrSubD(i*2) = arrV(i)
arrSubD(i*2+1) = Array( (arrV(i)(0) + arrV(i+1)(0))/ 2.0, _
(arrV(i)(1) + arrV(i+1)(1))/ 2.0, _
(arrV(i)(2) + arrV(i+1)(2))/ 2.0)
Next

arrSubD(UBound(arrSubD)) = arrV(UBound(arrV))
SubDividePolyline = Rhino.AddCurve(arrSubD)

End Function

No comments:

Post a Comment