Hi all, I’m still new to grasshopper and I ran into this problem I cannot comprehend.
What I was trying to do was dead simple: create a polyline from a list of 3d points. Inside the Script Editor I seem to have got a polyline object (see screenshot), but the python comonent output gives me a list of 3 point, not a polyline. The preview in Rhino is also just 3 separate points.
You probably want the PolylineCurve class, alternatively call the ToNurbsCurve() method on the Polyline. The reason a single Polyline will output as a list of points, is that it is essentially what it is (it inherits from the Point3D list class) and the GHPython component will see it as an iterable and try to get/output its values (ie the points).
This creates a tuple that capsulates the polyline. Grasshopper(or maybe Python) will see it as a list with one single item, so you will get the polyline as a single item.
The reason to put “,” at the end is that because (a) is ambiguous (can be either a tuple with a single item or simply a), Python syntax determines that, to create a single item tuple, you need to put , at the end.
I tend to call the ToNurbsCurve() myself, as it is quite explicit to anyone reading the code. Generally speaking though I rarely output a single polyline, and lists of polylines will output as expected as you point out