Is it possible to get names/list of selected Rois in RoiManager3D using a macro command




My macro opens RoiManager3D with some Rois. Next, the user has a chance to select several Rois. I would like to identify selected Rois if any. Saving selected Rois is not an option for me.

Is it possible to get names/list of all selected Rois in RoiManager3D ?

Any suggestion will be appreciated.


Looking at the list of available macro extension functions for 3D Roi Manager, I didn’t find an obvious way to get such a listing from a macro.

@ThomasBoudier please correct me if this is wrong.

When using any of the more powerful full-fledged scripting languages however, you can access the public Java API of the RoiManager3D_2 class and access its list of objects directly. The following Groovy script illustrates this:


manager = new RoiManager3D_2()

import ij.gui.WaitForUserDialog

new WaitForUserDialog("Add some objects, then press OK").show()

println manager.list.getSelectedValuesList()

Note: because the RoiManager3D doesn’t register with ImageJ’s WindowManager (which should be best practice for plugins that create new dialog windows), I didn’t find a way to access an existing 3D Manager window. Hence I had to start a new plugin instance and use a dialog to wait for user input. If someone knows a more elegant way, please suggest…


Thanks a lot for all your efforts and suggestion! I will try switching the language…


Hi @Astha and @imagejan,

I did not think of this, it is a good idea, it is added to 3DManager functions and will be available soon in the Fiji update. Thanks Jan for the registration to WindonManager, 3DManager should register properly now.

Here an example macro to get the selected objects :

run("3D Manager");
waitForUser("Select some objects in 3D, you may need to Deselect first to refresh list");
print("Selected objects:");
for(i=0;i<idx.length;i++) {
     print(idx[i]+" "+name);

Hope this helps



Thanks for the quick fixes, @ThomasBoudier, I believe the Ext.Manager3D_GetSelected(list) will be useful!

For those interested, the relevant commit is here:

As far as I can see from the source code, RoiManager3D_2 implements PlugIn, but doesn’t extend PlugInFrame. I would assume that you therefore have to take care yourself of not only adding, but also removing the window when it gets closed. Similarly, you might want to add:


to the windowActivated() method. See the B&C dialog for an example:


Hi Thomas,
Thanks a lot for your time and support!


Thanks @imagejan,

I will add this to the 3DManager.