Saturday, January 27, 2007

DrawLineFromCurve










The following is pretty basic script to take a curve to generate a straight line that has the same length with the original curve.



Option Explicit
'this script is created to unroll sphere
'so that hopefully I chould unroll little bit advanced shape.


UnrollSphere()
Sub UnrollSphere()

'Shpere should be ready
' -Circumference Max is 8'
' -Trimmed with 0 and 45 degree lines
' -Rebuilt Vertical Surf to U2, Vt
' -Extract wireframe



'Number of Division
Dim t
t = 8

Dim arrOrigin
arrOrigin = array(0,0,0)



'Get Length
Dim halfSphereCircumference1, dblLength

halfSphereCircumference1 = Rhino.GetObject("Select a circumference curve", 4)
If IsNull(halfSphereCircumference1) Then Exit Sub

dblLength = Rhino.CurveLength(halfSphereCircumference1)
Rhino.Print "Curve length: " & CStr(dblLength)




'Draw Line and Divide
Dim strStraight, arrCircumferenceCurvePoints

strStraight = Rhino.AddLine (arrOrigin, array(0,dblLength,0))



End Sub