How do I achieve "control point loft" in c#?


I would like to control loft degree by using the component “control point loft”. But How do I access this function in c#?

tackling the problem with some brute force… (7.5 KB)

1 Like

You actually invoke the CPLoft component inside C# script. That is smart. Thank you.
But please allow me continue, is there a way that I can “remake” control point loft?

not sure how the CPLoft works exactly but it seems you can try rebuilding each curve to the highest number of control points present in the collection, get all control points and do a NurbsSurface.CreateFromPoints()

1 Like

I got a problem. This method return “object” which cannot be convert or cast. How can I reuse the result inside C#? I upload the file here (8.5 KB)

That object is a DataTree.
Here is a really dirty fix:

 private void RunScript(DataTree<Curve> C, DataTree<int> D, ref object A, ref object B)
    nic.ComponentFunctionInfo loft = nic.Components.FindComponent("ControlPointLoft");
    string[] ermsg = null;
    object[] outparams = loft.Evaluate(new object[]{C, D, }, true, out ermsg);

    Grasshopper.DataTree<System.Object> tree = (Grasshopper.DataTree<System.Object>) outparams[0];

    Rhino.Geometry.Brep brep = (Rhino.Geometry.Brep) tree[new GH_Path(0), 0];
    A = brep;

    MeshingParameters mp = new MeshingParameters();
    Mesh [] meshes = Mesh.CreateFromBrep(brep, mp);
    mp.MaximumEdgeLength = 1;

    B = meshes;

    foreach (string s in ermsg)
1 Like

Thank you so much!