Passing Polyline parameter from Grasshopper to Component


I would like to ask if there is another way to pass Polyline to grasshopper component.

I am always declaring Curve parameters since there is no AddPolylineParameter option:

protected override void RegisterInputParams(GH_Component.GH_InputParamManager     pManager) {
        pManager.AddCurveParameter("TopPlines", "C0", "TopPlines", GH_ParamAccess.tree);

Then casting in the solution:

        int c = 0;
        for(int i = 0; i < c0.Branches.Count; i++) {

            List<Polyline> polylinesA = new List<Polyline>(c0.Branches[i].Count);
            foreach (GH_Curve curve in c0.Branches[i])
                Polyline pl;
                curve.Value.TryGetPolyline(out pl);


I C# editor I can directly use polylines without casting, is it possible to avoid this step also in compiled components?

The casting is performed elsewhere in the case of script components. You don’t actually skip that step.

Since there is no native Polyline type in Grasshopper, you have two options:

  1. Create your own data type, and your own parameter.
  2. Put your Polyline inside a GH_ObjectWrapper and use the Generic parameter.

Neither is ideal, the first is a lot of work and the latter means you’ve lost type constraints.

Thank you for the reply.
I will try to pass data by object wrapper to skip casting operation.