netDxf icon indicating copy to clipboard operation
netDxf copied to clipboard

How can I add new point to Spline.ControlPoints?

Open jim-jiang-github opened this issue 2 years ago • 2 comments

Spline.ControlPoints is a Array, and only Support getter no setter. How can I add new point to Spline.ControlPoints? Can only re-instantiate an object? If you re-instantiate an object, what parameters do you need to pass to Spline besides ControlPoints?

jim-jiang-github avatar Aug 01 '23 07:08 jim-jiang-github

You can use the Spline constructor public Spline(IEnumerable<Vector3> controlPoints, IEnumerable<double> weights, short degree, bool closedPeriodic)

As the "controlPoints" parameter pass your new array of Vector3 that represents your new control points list. As the "weights" parameter you can just pass null if you use the default value of one for the weights vector or you just do not know what is the purpose of it. If you do, you already know what to do with it. As the "degree" parameter pass the value of the property Degree of your previous spline. As the "closedPeriodic" parameter pass the value of the property IsClosedPeriodic of your previous spline.

haplokuon avatar Aug 01 '23 23:08 haplokuon

You can use the Spline constructor public Spline(IEnumerable<Vector3> controlPoints, IEnumerable<double> weights, short degree, bool closedPeriodic)

As the "controlPoints" parameter pass your new array of Vector3 that represents your new control points list. As the "weights" parameter you can just pass null if you use the default value of one for the weights vector or you just do not know what is the purpose of it. If you do, you already know what to do with it. As the "degree" parameter pass the value of the property Degree of your previous spline. As the "closedPeriodic" parameter pass the value of the property IsClosedPeriodic of your previous spline.

Thank you very much.

jim-jiang-github avatar Aug 02 '23 02:08 jim-jiang-github