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.

SolidworksApi macros
Answers 5
AT
AT 2016-02-22 Best Answer

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

JK
JK 2016-02-23

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)

JK
JK 2016-02-23

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?

JK
JK 2016-02-23

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);

AT
AT 2016-02-23

Great finding! Thank you for sharing the solution.