AttributeError: 'SalomeOutsideGUI' object has no attribute 'getAllSelected'

I am working on a python script. I load it into salome gui with “Load Script”. I then select a mesh group in the mesh module and launch the function of the script from the python console in the gui. My script use to identify the ID of the selected object.

It works in salome meca 2019. But in Salome 9.7 I get: AttributeError: ‘SalomeOutsideGUI’ object has no attribute ‘getAllSelected’
Do you know how to make it work in salome 9.7?

you should share your script (reproducer minimal version) to see if this can be reproduced.
Note that in SALOME 9.8, I did not manage to reproduce the reported issue: calling from a script does not trigger any error.

I ran into the same error some times ago. I changed the “” line by:

from salome.gui import helper
selectedMesh = helper.getSObjectSelected()[0].GetObject()

This will return the mesh selected. However, if you need more that one mesh, you may have to play a little with the above command.


Thank you for your inputs.
Yes I should scale down a minimal version…

I Have found out that if I start salome 9.7, then choose File + new + import a mesh, then run the script then it works. It seems that something goes wrong if I open a existing saved model with geometry and mesh already existing.

I also tried helper.getSObjectSelected()[0].GetObject() this works but the gui does not update after the script has run. The command gives the message “SalomeOutsideGUI: no objectBrowser update outside GUI”


Hi, I have attached two hdf examples which illustrate the problem. I am now running Salome 9.8.

Test2.hdf include a geometry in the shaper module and a mesh in the mesh module. If I open the file, activate the mesh module, select the mesh group VOL and type in the python console it returns a error message:
Traceback (most recent call last):
File “”, line 1, in
AttributeError: ‘SalomeOutsideGUI’ object has no attribute ‘getAllSelected’
=> Does not work

Test3.hdf include only a imported mesh. If I open the file, activate the mesh module, select the mesh group VOL and type in the python console it returns a value [‘0:1:1:3:14:1’]
=> OK it works.

Why does it not work in the first case ? -What is needed to make it work?

Test2.hdf (123.3 KB)
Test3.hdf (62.7 KB)

Thanks for the reproducer. It seems that the issue occurs if the geometry is created in SHAPER. We will raise the reported issue to our core developers.

In the meanwhile you can try the workaround suggested to me by @cbourcier (thanks!)

salome.salome_iapp.salome_iapp_initial=1 = salome.salome_iapp.salome_iapp_init(True)

then calling should run.

Thank you -the workaround worked ok!