IEnumerable again

Can someone remind me how to convert my Python list of parameters into an IEnumerable so that I can feed it to Curve.Split() ?

TIA

You can use the .NET List class with float type, see the second example here:

Edit 1: Although Curve.Split should work with a Python tuple or list as I recall :thinking:

Edit 2: Indeed, a normal Python tuple works:


230330_SplitCurve_00.gh (4.5 KB)

An alternative solution that should be faster (if computation time is critical) could be :

curve = Rhino.Geometry.LineCurve(Rhino.Geometry.Point3d(0, 0, 0), Rhino.Geometry.Point3d(10, 10, 0))
parameters = [1.0, 2.0, 3.0]
# Convert the list of parameters to an IEnumerable of doubles
parameters_ienumerable = System.Array[float](parameters)
split_curves = curve.Split(parameters_ienumerable)
Rhino.RhinoDoc.ActiveDoc.Objects.AddCurve(curve)
for split_curve in split_curves:
    Rhino.RhinoDoc.ActiveDoc.Objects.AddCurve(split_curve)
Rhino.RhinoDoc.ActiveDoc.Views.Redraw()

Since It’s IronPython which is based on .NET you can use

System.Array[type](variables)

Yes, that was my recollection too, but it wasn’t working… However, I found my mistake, now it is… :woozy_face:

Thanks, that’s also useful for the future!

Sorry for the bad info!

1 Like