Curve.MakeClosed Problem - maybe Bug?

Dear @dale
Dear Everybody

Rhinocommon can not close this attached Curve:

makeClosed_test_or_bug.3dm (32.8 KB)

Something is wrong with the complex Curve (green at the right) in the attached Document. The curve is the former Brep-Face-Outer-Loop of a solid, the solid is designed in Solidworks and imported as sldprt.

Rhinocommon s Curve.MakeClose returns true on this curve, but the Curve is not closed afterwards.

Curve.IsClosed; // false
Curve.MakeClose(0.001); // returns true
Curve.IsClosed; // still false

i used the attached command to test.
works fine on the left open rectangle-shape.

what is wrong ?

Thanks for your Help.

best Tom

 protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        const ObjectType filter = Rhino.DocObjects.ObjectType.Curve;
        Rhino.DocObjects.ObjRef objref;
        Rhino.Commands.Result rc = Rhino.Input.RhinoGet.GetOneObject("Select curve to close", false, filter, out objref);
        if (rc != Rhino.Commands.Result.Success || objref == null)
            return rc;

        Rhino.Geometry.Curve crv = objref.Curve();
        if (crv == null || crv.IsShort(Rhino.RhinoMath.ZeroTolerance))
            RhinoApp.WriteLine("Curve is short");
            return Rhino.Commands.Result.Failure;

        if (crv.IsClosed)
            RhinoApp.WriteLine("Curve already closed");
            return Rhino.Commands.Result.Success;

        if (crv.MakeClosed(doc.ModelAbsoluteTolerance))
            RhinoApp.WriteLine("MakeClose reports true");
        string message = crv.IsClosed?"closed":"still open";
        RhinoApp.WriteLine("Now the Curve is " + message);

            new ObjectAttributes()
                    Name = "ShoulBeClosedCrv",
                    ColorSource = ObjectColorSource.ColorFromObject,
                    ObjectColor = System.Drawing.Color.Red

        return Rhino.Commands.Result.Success;

With the green curve, the end of segment[6] != the start of segment[7] (distance=2.6283e-09). Thus if you run SelBadObjects, the curve will be selected.

Looks like if you explode/join the curve will report as ‘good’ and be closed.

– Dale

THANKS. Dale for the fast reply.
exploding and joining also was the workaround i just coded…

But what i did not understand, that the return parameter of MakeClosed is true
even the curve is still open

well - have a nice weekend

best Tom

MakeClosed basically ensure that the starting and ending points of the curve meet. Your curve had a gap in the middle…