Quantcast
Channel: Rhino Developer - McNeel Forum
Viewing all articles
Browse latest Browse all 8565

GetPoint.Option executes GetPoint.Get when clicking option in commandline

$
0
0

@seppeldue wrote:

Hi,
GetPoint Loop with options. When clicking on options in commandline, each time a new point is created on the canvas near the commandline. Also, when not using the RhinoApp_EscapeKeyPressed function, a point is created when pressing ESC.

What am i doing wrong?
Thanks :slightly_smiling_face:

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
        points.Clear();
        
        while (true)
        {
            m_escape_key_pressed = false;
            RhinoApp.EscapeKeyPressed += RhinoApp_EscapeKeyPressed;
            
            GetPoint getPoint = new GetPoint();
            getPoint.SetCommandPrompt("Please select point");
            
            var boolOptionAxis = new Rhino.Input.Custom.OptionToggle(front, "Front", "Side");
            getPoint.AddOptionToggle("MirrorPlane", ref boolOptionAxis);
            var boolOption = new Rhino.Input.Custom.OptionToggle(clamped, "Off", "On");
            getPoint.AddOptionToggle("Closed", ref boolOption);
            
            if (points.Count > 1)
                getPoint.DynamicDraw += DynDrawCurve;

            getPoint.AcceptNothing(true);
            if (getPoint.Get() == GetResult.Nothing) break;
            if (m_escape_key_pressed) break;

            clamped = boolOption.CurrentValue;
            front = boolOptionAxis.CurrentValue;

            if (front == false)
            {
                xm = -1;
                ym = 1;
            }
            if (front)
            {
                xm = 1;
                ym = -1;
            }

            Point3d pt0 = getPoint.Point();
            Point3d pt0M = new Point3d(xm*pt0.X, ym*pt0.Y, pt0.Z);
            int insert = points.Count / 2;
            points.Insert(insert, pt0);
            points.Insert(insert+1, pt0M);
        }

        NurbsCurve nc = NurbsCurve.Create(clamped, 3, points);

        RhinoApp.EscapeKeyPressed -= RhinoApp_EscapeKeyPressed;
        doc.Objects.AddCurve(nc);
        doc.Views.Redraw();

        return Result.Success;
    }

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 8565

Trending Articles