Collapse / Dissolve crv shorter than "X"

There is a difference between Polyline and PolylineCurve, see Polyline versus PolylineCurve - Rhino Developer - McNeel Forum

Here is a version for py3 in Rhino 8 using the code below.
2024-02-09_collapse_polyline_py.gh (7.9 KB)

import Rhino.Geometry as rg
polyline = rg.Polyline(polyline)
polyline.CollapseShortSegments(tolerance)

a = polyline.ToPolylineCurve()

the script node casts a polyline to a list of Point3d, which is why you’ll need to create a Polyline first in order to run the code. Might be a bug.

EDIT: On a side note: Personally I’m not a fan of using upper case variables as that can lead to bugs, especially when calling them the same as classes from libraries used. In this case e.g. a from Rhino.Geometry import Polyline will cause problems.

2 Likes