Feature Request "Best Fit Curve" or "CurveFitFromPoints"

Hi All,

I have a group of unordered points (attached) that I need to fit a curve through. Something like _Circle, _FitPoints although with a curve instead of a circle.

Initially I thought to use rs.AddCurve then rebuild it with less control points however as my points are unordered the curve jumps from one side to the other.

I have a lot of these groups and would like some way to automate this process. The result should look something like this:

Does anyone have any idea how to do this?


Unordered points for best fit curve.3dm (66.9 KB)

Hi wattzie,

This is just a quick suggestion - iterating through your unordered points and finding the closest one.
Play around with the number of final curve control points a little bit get some different shapes (for now it’s 19).

I think some guru around here might come up with a better solution.
edit: added checking for duplicate points.
fitCurveThroughPoints.py (2.1 KB)

1 Like

Wow thanks @djordje!

This works very well on the other other data sets I have.

Thanks for the help!