Bidirectional curve?

Why is this happening?
image
export.3dm (27.6 KB)

Folded back on itself? Check the end/control points…

1 Like

no, that’s the thing it’s not folded

My bad!

this curve is not caught by SelDup :frowning:
neither by Rhino.Geometry.GeometryBase.GeometryEquals

You’ll have to _ExtractPt to create the duplicate or stacked control points.
Do you mean it should _SelBadObject?

SelDup does not find stacked control points. SelDup does find duplicates of point objects. Control points are not individual objects.

no, duplicates

I found _Convert to be able to fix the curve.
Any ideas what RhinoCommon method is used in there?

I believe that is
https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Curve_Simplify.htm

1 Like

Thanks for the suggestion @Gijs
It turns out Simplify doesn’t work with Polylines :thinking:

sorry I think it should be this one:
https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Curve_ToArcsAndLines.htm

The original posted above is a degree 5 NURBS curve - SimplifyCrv seems to work on that to simplify it to a line…

:slight_smile: Yeah, I changed my strategy instead of using Silhouette I decided to use Mesh.GetOutline. That changed my result from curve to polyline.

SimplifyCrv seems to be able to merge colinear segments of polylines here… However, it uses a hard-coded (very fine) tolerance here for the angle below which adjoining segments are considered colinear. With Convert you can specify a tolerance. The RC version of SimplifyCrv - Curve.Simplify() does have both distance and angle tolerances as arguments.

Original polyline:

now using:

_ = _.ToPolylineCurve()
_.Simplify(Rhino.Geometry.CurveSimplifyOptions.All, sc.doc.ModelAbsoluteTolerance, sc.doc.ModelAngleToleranceRadians)

image

I don’t see any effect.

I need to convert this polyline somehow to something instead of just putting it in PolylineCurve “container”

Post the curve?

Rhino 6 or 7?
I’m testing this in RhinoWIP

OK, 7 then.

culprit.3dm (31.0 KB)

if you use the Convert command on this result is what I expect from Simplify

SimplifyCrv (native Rhino) gets me this:

That extra point is there because it’s actually the curve start point and Simplify does not cross start/end points if the curve is closed - one would need to move the curve seam to a corner to get rid of it. I will look into RC in a sec.

So, try this on for size:

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino

crvID=rs.GetObject("Select your curve",4)
if crvID:
    crv=rs.coercecurve(crvID)
    rc,pl=crv.TryGetPolyline()
    if rc:
        pl.MergeColinearSegments(sc.doc.ModelAngleToleranceRadians,True)
        sc.doc.Objects.Replace(crvID,pl)
        sc.doc.Views.Redraw()

1 Like