5 Replies Latest reply on Feb 23, 2016 5:06 PM by Artem Taturevych

# How to turn a piecewise linear curve into a spline ICurve

If I have a set of points how do I turn this into a spline ICurve? Are there any curve fitting API calls or will I have to do the fitting myself and then call one of the low level spline creation calls?

My use case is that I'm doing a non linear transformation of an input ICurve to an output ICurve. I do this by first sampling the input curve at a small enough interval. I then collect the points and want to generate a new ICurve.

• ###### Re: How to turn a piecewise linear curve into a spline ICurve

I'm afraid you need to implement this yourself. A quick search given only the standard spline fit function but none on the modeler level.

Thanks,
Artem

• ###### Re: How to turn a piecewise linear curve into a spline ICurve

Ok I have a library that can create a spline curve from a set of points. The result from this curve is

• Knots: Array of double
• ControlPoints : Array of Point4(X,Y,Z,W)
• Degree: double

How to translate this to the

2015 SOLIDWORKS API Help - CreateBsplineCurve Method (IModeler)

• ###### Re: How to turn a piecewise linear curve into a spline ICurve

I just discovered that the library I'm using is .Net 4.5 only. When will solidworks release support for .Net 4.5 and above?

• ###### Re: How to turn a piecewise linear curve into a spline ICurve

The solution that seems to work well is to create first a list of trimmed lines for each line segment.

ICurve [] lines = ...

Then merge these lines into a single curve and simplify with a tolerance

var curve = modeler.MergeCurves(lines).SimpifyBCurve(ChordTolerance);

• ###### Re: How to turn a piecewise linear curve into a spline ICurve

Great finding! Thank you for sharing the solution.