C#: Curve Subdivision


I have a C# code question I can’t solve. I hope someone can help me pointing in the right direction. I’m writing a curve subdivision code in C#, but I’m stuck at the last statement, which is creating a curve in the Rhino interface. Any help will be much appreciated.

   for (int j = 0; j < iterationCount; j++)
      List<Point3d> newControlPoints = new List<Point3d>();

      for (int i = 0; i < controlPoints.Count - 1; i++)
        Point3d oneQuarterPoint = 0.75 * controlPoints[i] + 0.25 * controlPoints[i + 1];

        Point3d threeQuarterPoint = 0.25 * controlPoints[i] + 0.25 * controlPoints[i + 1];

      controlPoints = newControlPoints;


    curve = new PolylineCurve(controlPoints);

Capture_2 19_1119_C#_Intro.gh (8.3 KB)

Seems you’ve not declared what curve is. If it is new and not an output then it should be.

PolylineCurve curve = new PolylineCurve(controlPoints);

If it is an output of a component then the output needs to be named curve.

1 Like

Yup, like @laurent_delrieu said… assign your curve to A

Also, your threeQuarters interpolation is not correct.

1 Like

@Michael_Pryor @laurent_delrieu @DavidRutten Thank you for your help. I got it now! :grinning: