algorithmic modeling for Rhino
Hi Fernando,
Please, upload the rhino file compatible with 4.0
Hola Fernando,
por favor, sube el archivo de rhino compatible con la versión 4.0
Thanks Albert but it is a Python code that only runs on Rhino 5!
Hi Fernando,
there are other ways to approach this altogether, but I think the attached file answers your question.
It is based on this code:
Lineas = [Lineas[i] for i,e in enumerate(D) if e!=0]
I hope this helps,
- Giulio
________________
giulio@mcneel.com
I think you can even remove the enumerate call and just get it down to
Lineas = [e for e in D if e!=0]
Thanks Steve! if I get the call to enumerate get an undesired result
Mh... this is interesting and makes me now wonder: what is the goal of this exercise?
What should each variable contain?
- Giulio
_________________
giulio@mcneel.com
And delete the values that repinten "D" is also repeated lines!
Usually what you are trying to obtain is approached in the following way, because of memory and to iterate through the whole list fewer times.
If you one day need to have the same lines twice (in the two directions), you could just construct the same line but with reversed inputs, or modify the loop for j so that it starts at the beginning of the list.import rhinoscriptsyntax as rs
L = [] # construct a new, empty list for L (lines)
D = []
for i in range(len(M) - 1):
for j in range(i + 1, len(M)):
if rs.PointCoordinates(M[i]) == rs.PointCoordinates(M[j]):
continue
line = rs.AddLine(M[i], M[j]) #if so, add the line
D.append(rs.CurveLength(line)) #also, compute the length
L.append(line)
I hope this helps,
- Giulio
____________
giulio@mcneel.com
Giulio Excellent I have a question. In quesaos is advisable to place "else" after the "if"
It would be good to create a group of style ( http://www.grasshopper3d.com/group/coffee-and-grasshopper ) amplar to knowledge of Python!
Studying your code I saw the condition that is within the "if" not met not by how they areraised loops, so you can remove this line correct?
Thanks for your tiermpo!
import rhinoscriptsyntax as rs
Lineas = [] # construct a new, empty list for L (lines)
D = []
for i in range(len(M) - 1):
for j in range(i + 1, len(M)):
#if rs.PointCoordinates(M[i]) == rs.PointCoordinates(M[j]):
# continue
line = rs.AddLine(M[i], M[j]) #if so, add the line
D.append(rs.CurveLength(line)) #also, compute the length
Lineas.append(line)
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
© 2024 Created by Scott Davidson. Powered by