I am debugging a TUI script, that in my case is done mostly in the Geometry module.
and a life improvement to the debuging of it, would be to be able to add some lines to the script so when run, the GUI opens de geometry module and furthermore, it updates/refreshes it (as F5 behavior in the GUI)
is there any way to achieve this? i could not find it in the documentation.
What do you mean by refresh? Display the GEOM object or simply update the SALOME Object browser?
In order to activate a module (switch to it) via Python, I used the following lines:
import SalomePyQt sgPyQt = SalomePyQt.SalomePyQt() sgPyQt.activateModule('Geom') # Or GEOM, forgot what is the correct string # And for example to refresh the SALOME Object browser import salome salome.sg.updateObjectBrowser()
first of all thanks for your help,
secondly, the correct string is ‘GEOM’, nevertheless, this gives a view setup that is not correctly, see screenshot, the tools are all misplaced and what is worst (and what I need) is that the object browser is not displayed.
this command throws an error when I add it to the script as following:
Traceback (most recent call last):
File “”, line 1, in
File “C:/Users/Microreactors/Documents/MEGAsync/These doctoral/OpenFoamSalomeFreeCad_ScriptsCases/structuredMeshingGenerator/structuredMeshingGenerator.py”, line 30, in
File “C:\SALOME-9.9.0\W64\GUI\lib\python3.6\site-packages\salome\libSALOME_Swig.py”, line 166, in
getattr = lambda self, name: _swig_getattr(self, SALOMEGUI_Swig, name)
File “C:\SALOME-9.9.0\W64\GUI\lib\python3.6\site-packages\salome\libSALOME_Swig.py”, line 80, in _swig_getattr
raise AttributeError(“‘%s’ object has no attribute ‘%s’” % (class_type.name, name))
AttributeError: ‘SALOMEGUI_Swig’ object has no attribute ‘updateObjectBrowser’
for info, i add it to my script before the
geompy = geomBuilder.New()
ah sorry, first I noticed that the updateObjectBrowser is the wrong function. The correct one is
In the meantime I will see how to show the Object Browser. I think there is Qt function exposed to python for most SALOME GUI functionalities.
the function works correctly, thank you a lot.
another questions if I may regarding the interaction between TUI and the GUI and whats is displayed,
regarding the SMESH module, how can we display a mesh and change its color in the view?
i got it done for the geometry module by using:
gg = salome.ImportComponentGUI("GEOM") for solid in solids: listDisplaySolids.append(geompy.addToStudy(solid,'solid '+str(countSolids))) for i in listDisplaySolids: gg.createAndDisplayGO(i) gg.setDisplayMode(i,2) gg.setColor(i,random.randint(0,255),random.randint(0,255),random.randint(0,255)) gg.setVerticesMode(i, False) gg.setTransparency(i,0)
is it possible to do the same for the SMESH module?
display in the VTK scene the different meshes, change the color of each of them to differentiate and lastly use the ‘fit all’ to show the view of them (this I did not found it either for the Geometry module, OCC scene)?
furthermore, the code that I cited in this post ‘works well and intended’, only after running the script if i copy paste it in the python console, but if I add it to the script that I am running from file/load script, for example, the solids will all be shown in the same color intead of having random colors for each of them.
you can call
display from smesh’s gui:
smesh_gui = salome.ImportComponentGUI('SMESH') mesh_id = salome.ObjectToID(Mesh_1.mesh) smesh_gui.display(mesh_id)
See available functions in SALOME Mesh Module Developer: SMESH_Swig Class Reference
And an example to manage the colors in this script:
create_and_display_box_v9.py (2,7 Ko)
thanks for the insight. I almost got everything I was looking for studying your script and looking in the documentation, nevertheless, i could not find one thing, how to display the display mode to ‘shrink’.
I found that
smesh_gui.properties we have the .shrinkFactor which will modify the this shrinkish that I am looking for, furthermore I found also
smesh_gui.setDisplayMode(group_id,1) which will change the display mode between nodes (0), wireFrame (1), shading (2). but i could not find how to change it to display mode/ shrink (then the .shrinkFactor will have an impact over the displayed view.)
how can I change to this display mode?
Shrink is also available from smesh_gui: