Optimization of curve rebuilding

Hi, I need to rebuild a curve imported from an external program. Is there any fuction that can optimize the curve where is needed? Actually in the curve there are small complex parts that need lot of points but the majority of the curve is simple so few points needed.
That should be done automatically without manually splitting the curve and rebuilding it locally.
Thanks.

Could you please shar us the curve file please. Thank you, Clemens

This is an example

Example.3dm (42.5 KB)

Simplification goals can be quite subjective. Please also provide what you want the outcome to be for this example.

This is already a good result. Optimization.3dm (28.5 KB)

Referring to the image below,

  • Exploded Example.3dm consists of 8 LineCurves (green) and 79 NurbsCurves (red). All the latter are single-spanned degree 3.
  • Exploded Optimization.3dm consists of 53 LineCurves (green) and 6 NurbsCurves. One (cyan) of the latter is degree 3 with 20 control points. The rest (red) are single-spanned degree 3.

The profiles deviate up through 2 mm.

Is the conversion to all the lines at the bottom intentional?

Maybe rhinoscript’s FitCurve ( rhinoscriptsyntax (rhino3d.com) ) will work for you. Just add tolerance arguments to the example:

import rhinoscriptsyntax as rs
oldCurve = rs.GetObject("Select curve to fit", rs.filter.curve)
if oldCurve:
    newCurve = rs.FitCurve(
        oldCurve,
        distance_tolerance=2.0,
        angle_tolerance=20.0)
    if newCurve: rs.DeleteObject(oldCurve)

image