algorithmic modeling for Rhino
hi Fabio
You need to use a list to collect generated by a straight line.
import rhinoscriptsyntax as rs
def lines(x,y,z):
lines = []
pt1 = rs.DivideCurve(x,z)
pt2 = rs.DivideCurve(y,z)
for i in xrange(z):
line = rs.AddLine(pt1[i],pt2[i])
lines.append(line)
return lines
a = lines(x,y,divnum)
hi naruto,
thanks for your reply. I have tried to apply your suggestion to the function but as you can see, it still does not return a list of lines.
what I don't understand is why do we need to create a list of a list? and why the divideCurve command, for example, does not need a list to append the result of the command itself?
Naruto,
rs.AddLine returns the GUID of the line that is created not the line itself. If you want the curve geometry you can call rs.coercecurve().
import rhinoscriptsyntax as rs
def lines(crv1,crv2,divisions):
linesList = []
pt1 = rs.DivideCurve(crv1,divisions)
pt2 = rs.DivideCurve(crv2,divisions)
for i in xrange(0, divisions):
lines = rs.coercecurve(rs.AddLine(pt1[i],pt2[i]))
linesList.append(lines)
return linesList
a = lines(x,y,n_div)
Yes you're correct NARUTO. I thought that was the case. I didn't see the 'lines.append(line)' had also dropped out of the initial loop in Fabio's attachment. Which was the problem.
Miss read the code. Thanks for the clarification.
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