Mesh pipe through C#

Can you please tell me what the error is trying to write a mesh pipe component, but the method produces a lot of errors

pipe.gh (7.1 KB)

  • The method “CreateFromCurvePipe” is a static method, which means you need to start the method call from the class holding the method, in this case from the Mesh class. See documentation here.

  • You also feed the component with a LIST of curves (from edges), but the Pipe-command takes only single curves as the curve argument. So you need to iterate over the curve list and create the pipes individually. In my reply I renamed the “curve” input to “curves”. See code example below.

  • The capType is an enumeration, which looks like an integer (yes), but it’s not actually a integer TYPE, it’s a MeshPipeCapStyle type, so you need to type-cast the integer into a MeshPipeCapStyle, see the “cap_style” variable below.

    // Wrong:
    // M = CreateFromCurvePipe(curve, radius, segments, accuracy, capType);

    // Correct
    var pipes = new List<Mesh>();
    var cap_style = (MeshPipeCapStyle) capType;
    
    // iterate over the curve *list*
    foreach (var curve in curves)
    {
      // Static methods requires starting the method call from the base class; "Mesh.<method>":
      var mesh_pipe = Mesh.CreateFromCurvePipe(curve, radius, segments, accuracy, cap_style, true);
      pipes.Add(mesh_pipe);
    }
    M = pipes;

This code results in the following model:

The modified component here:
pipe_RE.gh (10.4 KB)

// Rolf

1 Like

Rolf, Thank you very much for your help, thanks!

Hello,
Can you please tell me I’m trying to transfer the code for building pipes to the grasshopper plugin, the node is compiled, but in the process of salting out the node, the following error occurs

  1. Floating parameter Mesh failed to collect data

Can you please see the code where I am wrong? code for the node attached txt file
And for some reason, the code runtime in the plugin variant is longer than just through the nod C#?

MeshPipe.txt (3.6 KB)

DA.SetDataList(0,outputMeshPipe);
rather than
DA.SetData(0,outputMeshPipe);

I don’t know about the speed, but can you try the change of the output first.

1 Like

Thank you very much did not notice the error :slightly_smiling_face:

Mesh Tools, Yellow, and Ngon plugins have this mesh pipe already btw. Are you adding some additional functionality? Difference in speed is probably because of your error.

1 Like

Yes, I saw this component in plugins, I study and make simple nodes to learn how to work and create plugins myself :slightly_smiling_face:
corrected the error began to work quickly :+1:

1 Like