RhinoGet.GetBool: How?

Hi
How i can fix this code to make it enable Display Pipeline when true and disable it when false?

public override string EnglishName => "MouseClickEnable";
        readonly MouseClickEvent mevent = new MouseClickEvent();
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            var conduit = new MouseClickConduit();

            bool choice = false;
            Rhino.Input.RhinoGet.GetBool("MouseClick", false, "Disable", "Enable", ref choice);

            if (choice == true)
            {
                mevent.Enabled = true;
                conduit.Enabled = true;  
            }
            doc.Views.Redraw();

            if (choice == false)
            {
                mevent.Enabled = false;
                conduit.Enabled = false;  
            }
            doc.Views.Redraw();
            return Result.Success;
        }

This work fine

In the initial code you create a conduit each time the command is run. So the old conduit never gets disabled. The second code, you have one static instance that is used each time the command is run.

2 Likes