Only first GetObject instance is working

I’m getting really odd behavior with this one, what am I missing? This code will not give me the prompt for the second curve and ands the first twice to the document instead …

        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            // TODO: start here modifying the behaviour of your command.
            // ---
            var go = new GetObject();
            go.SetCommandPrompt("select curve1");
            go.GeometryFilter = Rhino.DocObjects.ObjectType.Curve;
            go.Get();
            if (go.CommandResult() != Result.Success)
                return Result.Failure;
            Rhino.DocObjects.ObjRef obj = go.Object(0);
            Curve c = obj.Curve();
            doc.Objects.AddCurve(c);

            var go2 = new GetObject();
            go2.SetCommandPrompt("select curve2");
            go2.GeometryFilter = Rhino.DocObjects.ObjectType.Curve;
            go2.Get();
            if (go2.CommandResult() != Result.Success)
                return Result.Failure;
            Rhino.DocObjects.ObjRef obj2 = go2.Object(0);
            Curve c2 = obj2.Curve();
            doc.Objects.AddCurve(c2);

            // ---

            return Result.Success;
        }

Use doc.Objects.UnselectAll() before go2.Get()
or
go2.DisablePreSelect()

Multiple Get Objects

1 Like