Combine similar segments in polyline

Hi,

Just wondering if someone knows of a simple/straightforward way to take a polyline and run through all of its segments, see if any of them are connected to each other and going in the same direction, and then replace those portions with a single segment. By polyline, this would be a collection of degree 1 curves connected together.

I imagine this has to be scripted but if there is a native gh way to do this then that would be even better.

Thanks
Devin


Discontinuity sort of does that.
You can use the discontinuity points to build a new polyline.

https://developer.rhino3d.com/wip/api/RhinoCommon/html/M_Rhino_Geometry_PolyCurve_CleanUp.htm

The Polyline class also has several methods that might be relevant:

https://developer.rhino3d.com/wip/api/RhinoCommon/html/M_Rhino_Geometry_Polyline_MergeColinearSegments.htm

https://developer.rhino3d.com/wip/api/RhinoCommon/html/M_Rhino_Geometry_Polyline_RemoveNearlyEqualSubsequentPoints.htm

https://developer.rhino3d.com/wip/api/RhinoCommon/html/M_Rhino_Geometry_Polyline_DeleteShortSegments.htm

https://developer.rhino3d.com/wip/api/RhinoCommon/html/M_Rhino_Geometry_Polyline_CollapseShortSegments.htm

1 Like

Thanks @maje90 @dale and @AndersDeleuran

I ended up using the MergeColinearSegments to achieve what I was looking for. I wasn’t quite sure how to run CleanUp on ‘Polyline Curves.’

1 Like