How to convert the data tree of curve using AddLoftSrf?

I want to make and loft arbitrarily selected curves from the data tree.
But my Grasshopper & GHPython is showing two errors.

This is GH data. (12.9 KB)

1. I don’t understand Runtime error
Putting curves in the list doesn’t work.

import rhinoscriptsyntax as rs
from Grasshopper.Kernel.Data import GH_Path
c1 = _curve.Branch(GH_Path(0, 7))
c2 = _curve.Branch(GH_Path(0, 5))
srf = rs.AddLoftSrf(curves)
result = srf

2. I don’t understand ’ Data conversion failed from Goo to Curve '
I cannot store listed curves.

Please your advice …



It is due to the fact that you pass a nested list to rs.AddLoftSrf() instead of a list of GUIDs, pointing to curves. c1 and c2 are of type List[object].
In your case, you can unpack the GUIDs like this:

c1 = _curve.Branch(GH_Path(0, 7))[0]
c2 = _curve.Branch(GH_Path(0, 5))[0]

This is the same issue as above. The Curve component is unable to unpack nested lists. It expects a single item, list of items, or data tree. It doesn’t know about nested lists. The same fix as above also solves this issue.

If you’re ever unsure about the type of a variable, you can always print(type(variable)) to take a peek.

Thanks so much your time and reply !
I was able to understand the error with your careful advice.
I didn’t understand how to get a nested index and how nested lists work.

I’ll use this to check as I go along.

Thanks so much!!

1 Like