BUG Curve.ToArcsAndLines

Hi,

I’m running into a bug in Curve.ToArcsAndLines.

The result on the attached curve is degraded starting in Rhino7
What I observe is that corners are being cut by chamfer type additional lines.
input_curve.3dm (23.5 KB)

To replicate, run the python script below in V6 V7 and V8

Any help is appreciated to work around this, or point out what I might be doing wrong here.

Thanks
-Willem

import Rhino.Geometry as RG
import math

import scriptcontext as sc
import rhinoscriptsyntax as rs

curve_id = rs.SelectedObjects()[0]
curve = rs.coercecurve(curve_id)

tolerance = 0.3
angleTolerance = math.radians(2)
minimumLength = 1
maximumLength = 0

new_curve = curve.ToArcsAndLines(tolerance, angleTolerance, minimumLength, maximumLength)

new_id = sc.doc.Objects.AddCurve(new_curve)
rs.UnselectAllObjects()
rs.SelectObject(new_id)

Note that decreasing minimumLength tolerance will yield a visibily better result but still there is an additional line cutting the corners.

1 Like

Hey @Willem - a minimum length of 0 seems to work.

– Dale

Hi Dale,
I also think that this is a bug which should be fixed.
ToArcsAndLines should not change line segments of a polycurve and chamfer corners.
I have plugins out which rely on this function.
Thanks, Jess

Hi @dale

Thanks for the reply.

Would you classify that as a workaround or solution?

Setting minimum length to 0 will still be a regression from the V6 functionally.

-Willem

1 Like

@Willem can you send a sample that gives the correct result in Rhino 6 with minimum length 1 that gives you a different result with minimum length 0?

Hi @dale

hope this info helps to fix the bug:
If a polycurve description contains segments of type Polyline then it looks like maximumLength does not recognize it as separate line segments, which of course should not be changed.

This is not just the the case with RhinoCommon, it also fails with the _Convert command.

Thanks, Jess

Edit: @Willem - a workaround would be to convert polycurves _ToNurbs
nurbs_curve = curve.ToNurbsCurve()

2 Likes

Hi Gijs,

I was unable to provide such example.
Possibly if I had more time to test run on more curves but unfortunately I do not have more time for that.

For now I use the workaround from Jess to convert the PolyCurve to NurbsCurve first.

Groet,
Willem

Hi @Jess

Thank you very much for digging in and sharing your result.

I’ll be using the workaround for now, this seems a good enough solution for now.

-Willem