Python problem ironpython

Rhino works perfect, Grasshopper works perfect, Python works perfect, but I am doing something wrong again.
How to convert Guid objects to curves?

I made a screenshot of a part because the script is to large.
Thank you for your response. :slight_smile:

You need to give us a slightly bigger hint on what you are trying to do - what do your guid objects represent? Points?
What type of curve do you want to create? A straight line between 2 points? :confused:
A curve from a python list of point guids?

I did

curve = rs.AddLine(pnA, pnB)

From it a Guid object is created. What am I doing wrong? The manual says that the function creates a Guid too. But, how do I output it as a curve?

You’re returning a function, not a guid nor a RhinoCommon object (e.g. a curve). Again, it is literally impossible for anyone to help without you uploading a (minimal) executable example to troubleshoot.

1 Like

Okay, I made something that creates the similar problem. So, how can I get the curves out of it? Do you might know?
What am I doing wrong?

20190122 problem ironpython 00.gh (7.7 KB)

Hi try adding () after your function call to run the function g.make_lines()
Otherwise you are assigning the function to lines. I get a group of Ironpython lists this way

You’re not calling the class method return_alllines() properly, and hence the method itself is returned:

Functions/methods are called with brackets:

But more to the point, you don’t need a get method, you can simply access the alllines property directly:

1 Like

By the way, you can use zip() or izip() to achieve crossline more efficiently:

from itertools import izip

    def crossline(self, pntsx, pntsy):
        lines = []
        for x,y in izip(pntsx, pntsy):
            line = rs.AddLine(x, y)
            lines.append(line)
        return lines

or in a line:

    def crossline(self, pntsx, pntsy): return [rs.AddLine(x,y) for x,y in zip(pntsx, pntsy)]
1 Like

Thank you for your response.
So, do you might know how I can get curves out of those IronPython lists?

Assuming it is a two-dimensional python list (of lists of curves), you could either flatten the list (i.e. make an empty list, iterate your curves lists, and extend the empty list with these) or convert it to a DataTree (using the data tree helpers, or like so).

I am still doing something wrong.
Yes, it is a list of curves, but I do not know how to retrieve it.

20190122 problem ironpython 01.gh (9.4 KB)

Your stepa variable is not a list of lists of curves, it has both single elements and lists:

Knowing how to inspect your variables and check your assumptions is step #1 in debugging.

1 Like

Probably you need to call extend instead of append. (if nested list was intentional and how to convert it to GH_Tree was the main question, just disregard this post…)

lines=self.line(self.pntsa)    #lines is a list of lines
self.alllines.extend(lines)    #call extend instead of append. You will get a flattened list.

But something strange for me is that “lines” are already added to alllines in function self.line().
Two solutions from me.

  1. comment out append(line) in both line() and crossline() and call alllines.extend(lines) in make_lines()
  2. keep append(line) in line() and crossline(). comment out self.alllines.append(lines) in make_lines()
1 Like

Thank you :slight_smile: