Selection during a command via separate UI

In our C++ plugin, we have a UI that lists the objects the user has made, and their relationships to each other.

We would like the user to be able to click the entry in the UI and select the object. This works when a command isn’t running, by our code calling RhinoApp().RunScript with -_SelID [UUID].

However, if a command is running, RunScript doesn’t work. Which makes sense, scripts can change the document state and commands need to specify they support that.

Our current fallback is to call Select(true) on the Object (which is a CRhinoObject implementation). While this makes the object appear selected (outline color changes), the running command does not realize an object has been selected.

Is there a proper way to do selection via our UI while a command is running? For example, from the menu, I can click Edit → Select by Name → Then pick from that UI, and the command will response appropriately. It would be ideal if our UI behaves the same way.

Hi @Peter_Newman

Try adding an apostrophe in front of the command.

'_SelId 4eb23f97-7c36-4ae3-8f8e-483c97a883c3

– Dale

Unfortunately, this doesn’t seem to help.

Attached is an image of this working outside of a command (with echo mode enabled for diagnostic purposes). But when a command runs (in this case, Move), the script is processed differently. As you can see, only the first term of the script appears on the command line, and the Move command does not recognize a selection has happened (nor does the object appear selected in the views). After that, any additional selections via our UI do not appear in the command line at all.


Just to test, I tried both RhinoApp().RunScript and RhinoApp().RunMenuScript() but both had the same behavior. I also tried using the CRhinoScriptContext version of RunScript, with and without specifying the current CRhinoDoc, resulting in the same behavior each time.

Hi @Peter_Newman,

What is your UI? Model dialog? Semi-modal dialog? Docking panel?

Just trying to figure out how I can replicate.

– Dale

Sorry for the delay getting back to you.

The UI is a CRhinoUiDockBar (so, docking panel).

The DockBarClientWnd is a class inheriting from CRhinoUiDockBarDialog . On that is a CTreeCtrl derived control.

The tree control describes the hierarchical relationships between our objects. On selecting an item in the tree, we want to do the selection as described above.

Hi @Peter_Newman,

One common trick is to have a hidden (test) command that inherits from CRhinoSelCommand, and have your modeless UI run the command. I’ve attached a sample for you to review. (29.8 KB)

– Dale