Can SimplifyCrv be made to fix/eliminate too-short segments?

I have a group of curves that refuse to simplify into polylines, they remain polycurves despite the fact that all the segments are degree 1 - in fact SelPolyline does select the curve. The reason is the fact that they contain a number of micro segments (due to a massive scale reduction). Could SimplifyCrv be improved to eliminate micro segments? Below is a sample.

NoPolyline.3dm (46.5 KB)

If I Explode, SelShortCrv (file tolerance), Delete any short segments, then Join, the curve will then simplify into one polyline. Of course, it’s possible that there wil be enough short segments end-to-end that when deleted the finished curve will have a gap of more than 2X file tolerance. In that case SimplifyCrv could warn the user and give up and leave the curve alone.


1 Like

Hi Mitch,

FYI there is a RhinoCommon method in the Curve Class to do this:


the functionality you are after is in GH as Polyline Collapse.

you can try and use the node to code:

import rhinoscriptsyntax as rs
import ghpythonlib.components as ghcomp

curve = rs.GetCurveObject("get curve",rs.filter.curve)[0]
tol = rs.GetReal("Collapse Tolerance")

if (rs.IsPolyline(curve)):
    newCurve = ghcomp.PolylineCollapse(curve,tol)
    points = rs.CurvePoints(newCurve[0])
    print "Number of Segments Deleted: " + str(newCurve[1])

Yeah, thanks guys - I have experimented with RemoveshortSegments as well as RemoveNesting and in the PolylineClass DeleteShortSegments. I have had mixed results…

However the post was simply a request to add that functionality to SimplifyCrv for the “ordinary user” who doesn’t have scripting capabilities. A lot of topographical data ends up like this especially when it is scaled down for modelmaking purposes. And having polylines instead of polycurves is important for file transfer to some of our machines. Just using plain Convert also can work, however on this particular curve, it also just fails silently.



This is also directly in RhinoCommon as Rhino.Geometry.Polyline.CollapseShortSegments() --Mitch

I think the test should be whether the curve ends up well within tolerance. A bunch of short segments that are close enough to linear could be made a single line segment.

The same thing should apply to spline curves. Splines with knots that are too close to be useful should be removed by simplifycrv. The test is the same - the end result should be a simpler curve that will still be well within the tolerance of the original.
Duplicate knots should also be removed when they are superfluous. If you take a spline curve and split it into 2 pieces and join the pieces into a polycurve then simplifycrv should be able to restore the original curve. This already usually works for lines and arcs but should work for splines also.

The goal of simplifycrv should be to get rid of complexity that is adding nothing but trouble to the curve.

Hi Mitch, for now, Explode/Join sorts it out - V6 does some cleanup, I think, that V5 does not. Explode/Join results in two curves - one micro segment on its own, and a polyline.


looking for any excuse to write a bit of code :grin: