generative modeling for Rhino
Tags:
Permalink Reply by Alberto Moral on April 22, 2012 at 2:09pm 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
Permalink Reply by fernando molas garcia on April 22, 2012 at 2:28pm Thanks Albert but it is a Python code that only runs on Rhino 5!
Permalink Reply by Giulio Piacentino on April 23, 2012 at 2:43am 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]
Permalink Reply by fernando molas garcia on April 23, 2012 at 11:54am Thanks Steve! if I get the call to enumerate get an undesired result
Permalink Reply by Giulio Piacentino on April 23, 2012 at 12:07pm 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
Permalink Reply by fernando molas garcia on April 23, 2012 at 2:06pm
Permalink Reply by fernando molas garcia on April 23, 2012 at 1:03pm And delete the values that repinten "D" is also repeated lines!
Permalink Reply by Giulio Piacentino on April 23, 2012 at 3:01pm 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
Permalink Reply by fernando molas garcia on April 24, 2012 at 11:12am 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!
Permalink Reply by fernando molas garcia on April 24, 2012 at 11:21am 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)
Added by Mgeorgio 0 Comments 0 Likes
Added by Mgeorgio 0 Comments 0 Likes
© 2013 Created by Scott Davidson.
Powered by