algorithmic modeling for Rhino
Hi everybody!
I am new to this discussion group and would appreciate your help.
I've run into the following problem:
- I have a group of lines, each of the lines points into different direction.
- I would like to move/arrange them in a way that the ending point of one line would be the starting point of another line.
- Starting point of the first line would be 0,0,0.
- The lines would arrange automatically.
Could anybody give me some advice or suggestions? Thanks a lot!
Tags:
Replies are closed for this discussion.
What would be the rule that says which line is the next one to be placed end to start or is it your intention that the placement be random?
Chris
Here's a Rhinoscript that will do this (randomly unless you pick the lines one at a time in the order you want them to be placed).
Chris
Option Explicit
'Arranges a set of lines head to tail, joins them and places the polyline at (0,0,0).
Call Main()
Sub Main()
Dim arrObjects,i,arrStart,arrEnd,arrVector,arrXform,arrJoined
arrObjects = Rhino.GetObjects("Select lines to arrange head to tail.",4)
If Not IsArray(arrObjects) Then Exit Sub
For i=0 To Ubound(arrObjects)-1
arrStart=Rhino.CurveStartPoint(arrObjects(i+1))
arrEnd=Rhino.CurveEndPoint(arrObjects(i))
arrVector = Rhino.VectorCreate(arrEnd,arrStart)
arrXform = Rhino.XformTranslation(arrVector)
Call Rhino.TransformObject(arrObjects(i+1), arrXform)
Next
arrJoined=Rhino.JoinCurves(arrObjects,True)
arrStart=Rhino.CurveStartPoint(arrJoined(0))
arrVector=Rhino.VectorCreate(Array(0,0,0),arrStart)
arrXform=Rhino.XformTranslation(arrVector)
Call Rhino.TransformObject(arrJoined(0),arrXform)
End Sub
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by