Tuesday, February 12, 2008
Ready for Another Lattice?
Here is another practical script for making physical models. I have to explode polylines manually first, then select the segment curves in order to layout for print (with little markers). Since "orient curve" command keeps working in a Loop, I have to Esc out the script, or simply reDim "i" manually for every round.
Option Explicit
layoutPolyline
Sub layoutPolyline
Dim strLine01, strLine02, strLineSave, i, j, arrReference, arrTarget
Dim arrCurve01S, arrCurve01E, arrCurve02S, arrCurve02E
Dim arrTarget1, arrTarget2, strMarker
i = 4
j = i + 0.75
'select an initial line to duplicate and hide
strLine01 = Rhino.GetObject ("select a line", 4)
strLineSave = Rhino.CopyObject (strLine01)
Call Rhino.HideObject(strLineSave)
'orient the line
arrCurve01S = Rhino.CurveStartPoint (strLine01)
arrCurve01E = Rhino.CurveEndPoint (strLine01)
arrReference = Array (arrCurve01S,arrCurve01E)
arrTarget1 = Array (0,-i, 0)
arrTarget2 = Array (99999,-i, 0)
arrTarget = Array (arrTarget1,arrTarget2)
strLine01 = Rhino.OrientObject (strLine01, arrReference, arrTarget)
strMarker = Rhino.AddLine (arrTarget1, Array(0,-j,0))
'select the succeding lines in order
Do
'duplicate and hide
strLine02 = Rhino.GetObject ("select the next line", 4)
strLineSave = Rhino.CopyObject (strLine02)
Call Rhino.HideObject(strLineSave)
'orient lines
arrCurve02S = Rhino.CurveStartPoint (strLine02)
arrCurve02E = Rhino.CurveEndPoint (strLine02)
arrReference = Array (arrCurve02S,arrCurve02E)
arrTarget1 = Array (0,-i, 0)
arrTarget2 = Array (99999,-i, 0)
arrTarget = Array (arrTarget1,arrTarget2)
strLine02 = Rhino.OrientObject (strLine02, arrReference, arrTarget)
arrCurve01S = Rhino.CurveStartPoint (strLine01)
arrCurve01E = Rhino.CurveEndPoint (strLine01)
arrCurve02S = Rhino.CurveStartPoint (strLine02)
arrCurve02E = Rhino.CurveEndPoint (strLine02)
Call Rhino.MoveObject (strLine02, arrCurve02S, arrCurve01E)
Call Rhino.CopyObject (strMarker, arrTarget1, arrCurve01E)
strLine01 = strLine02
Loop
End Sub