Passing RhioObject between events after windowsform is shown

Hello,

Now I am trying to make a command with ModelessForm dialog.

The command is supposed to be like,

  1. Start a custom command.
  2. ModelessForm form dialog is shown
  3. Automatically GetObject method starts.
    4.Transform the object with button_clicked event.

Now, I use “Form_Shown” event for GetObject method.

private void Form_Shown(Object sender, EventArgs e)
{
var go = new GetObject();
go.Get()
RhinoObject obj = go.Object(0).Object();
}

The GetObject method works ok that I could pick up some object.
However, I could not find the next way which how to pass the RhinoObject to button_clicked event.

If anyone give me some advise, I would appreciate.

Kato

You can actually save the obj or objectid in a property of your custom command class, then just access the instance of this command and read the propertys value.
eg

public class TestCommand : Command
    {
        public RhinoObject RhObject {get; private set;} 

        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            var go = new GetObject();
            go.Get()
           this.RhObject = go.Object(0).Object();
            
            return Result.Success;
        }
    }

and inside your modeless form, something like:

var myObject = Testcommand.Instance.RhObject;

Notice that you have to include a using statement for the TestCommand in this case if they are not in the same namespace.

.

Thanks Roger!
You saved my life!