Gh python: error working with coercecurve but not in Rhino python editor


Running my script from the Rhino Python editor does not produce any errors, a similar script embedded in Gh as a component however, does:
After filtering a curve input for deg=1 , I am trying to create a vector in the direction of the lines and use its start-/Endpoint for a series of transformations.
In Gh python I get the follwing errors:
using rs.CurveStartPoint(Id): Unable to convert Id into curve

Earlier in the script I use a filter with rs.coercecurve on every id in the list, only the segments of an exploded polyline not.

Using Rhino.geo.curve.PointAtStart(Id): I get an error message working with the start/endpoin a few lines latert: could not convert property PointAtEnd to a point3d.

Fed to the script are a rectangle and four lines forming a pyramid.
I assume it has to do with the rectangle-polyline, which components should be added to the list, but the polyline id removed;

It would be amazing if you can help me pinpoint how the error can be avoided.
Any general advice or improvements are much appreciated, too, as I am only starting to learn scripting.

Attached you can find screenshots, the grasshopper setup with the ghpython script and the working rhino script.

gh (9.5 KB)
grasshopper assembly.3dm (820.2 KB)

Thank you very much, with best regards,

Mero Script V2, (2.4 KB)

Hello Aero,

it’s kind of hard to see what you are really trying to do. If I get you right, you are just trying to get the vectors along a line or polyline. This doesn’t need any Rhino common scripting and can be achieved simpler and easier to understand. Take a look at this script and try to continue from there: (518 Bytes) (11.3 KB)

1 Like

Thanks, Peter, for taking the time to understand the issue. You’re a genius! It is beautiful that it is this simple.
I will implement your solution later today.

Though you solved the issue, in order to understand the program better, I would still like to know why I got the error messages in my script. Can you see what caused them?

I didn’t invest a lot of time into the actual error message. From what I know the phyton editor in grasshopper won’t necessarily provide all the functions that the Rhino library offers. If you want to program with the python editor in grasshopper I would recommend using the rhinoscriptsyntax prior to the Rhino library.