.CreateFromLoft() returns error message in Python

The objective is to create a loft surface in Rhino. I want to achieve this by using Rhino.Compute in Python. The loft is supposed to be based on two circles created using Rhino3DM. I am seeking clarification on the correct parameter types for the .CreateFromLoft() method as I think that the problem lies in the definition of the argument types.

This is the code I was attempting to use:

import rhino3dm as r3d
import compute_rhino3d.Util
import compute_rhino3d.Brep
import compute_rhino3d.NurbsCurve

compute_rhino3d.Util.authToken = "token"

model = r3d.File3dm()

curves = []

circle = r3d.Circle(r3d.Point3d(0,0,0),1).ToNurbsCurve()
circle2 = r3d.Circle(r3d.Point3d(0,0,10),10).ToNurbsCurve()

curves.append(circle)
curves.append(circle2)

model.Objects.AddCurve(circle)
model.Objects.AddCurve(circle2)

loft_breps = compute_rhino3d.Brep.CreateFromLoft(curves, r3d.Point3d.Unset, r3d.Point3d.Unset, 0, False)

model.Objects.AddBrep(loft_breps)

output_filename = r"path"
model.Write(output_filename, 8)

When executing the code, an error message is received that indicates incorrect arguments have been provided. Therefore, I would like to know how I should call this method to ensure that the code works. Are there any code snippets I could use as an example?
Any help is appreciated! :grinning_face:

Welcome to the forums @Clemens_Rausch,

There are some API guies here → https://developer.rhino3d.com/api/ that may be of use :slight_smile:

Thanks for the fast response! Thanks for sharing the API guide with me. Unfortunately I already knew that website. I can see that the Brep.CreateFromLoft() method requires an IEnumerable List. As far as I know, this type of list is generally being found in C. How does one do this in Pyhton?

You can create a c# List using python 3 with

from System.Collections.Generic import List
from Rhino.Geometry import Curve;

curves = List[Curve]()

And then add using curves.Add(curve)

Thanks for the advice! I was just going to try this out. However I have problems importing from Rhino.Geometry import Curve;
Could you tell what me the prerequisites are or how to import this properly?

Your “curves” variable should be recognized as a IEnumerable List.

I think your problem is with the loft type.
You need to insert Rhino.Geometry.LoftType.Normal as your argument for loft type instead of using 0. Either use that directly or assign a vatiable to Rhino.Geometry.LoftType.Normal and use that as the loft type argument `

Its pretty dumb that the documentation tells you Rhino.Geometry.LoftType.Normal=0 but then won’t allow zero as an argument.

Remove the semi-colon maybe? → from Rhino.Geometry import Curve

It would be more useful if you copied and pasted the actual error you are getting here, that way we don’t have to guess at what could be the issue.

edit:

ah, you’re not using RhinoCommon, running inside Rhino. You’re running outside of Rhino, that’s why you can’t do from Rhino.Geometry import Curve.

Brep.CreateFromLoft in compute does not take an IEnumerable: Brep — compute_rhino3d 0.14.0 documentation

Can you copy and paste the exact error you are getting?