Grasshopper

algorithmic modeling for Rhino

Hi,

can anyone please clarify why the function doesn't return a series of horizontal lines between the curves instead of one single line (assigned to an apparent random value of 9) as shown in the pic attached? 

thanks in advance

fabio.

 

Views: 562

Replies to This Discussion

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?

Attachments:

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)

HI Mat

If you don't call rhinocommon,You don't need to use rs. Coercecurve () function  convert t guid  to curce class,Because rhinoscriptsyntax need  guid  or string.

 

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.

 thank you naruto and matt for taking time to reply. all is clear.  

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service