I am having a problem running a python script on Ubuntu 22 in salome that I used in Version 9.8 before.
It calls for the function salome.sg.getAllSelected() but that function call results in the following error message:
AttributeError: ‘SalomeOutsideGUI’ object has no attribute ‘getAllSelected’. Did you mean: ‘getSelected’?
When looking through the documentation on python script integration, the function should still be working.
Any ideas how to fix it?
Thank you in advance!
Do you launch your script from the graphic interface?
salome.sg.getAllSelected() works for me in SALOME 9.9.0.
Thank you for your reply! Yes, I launch the script from the graphical interface pressing Ctrl+T and then calling the function triSurf().writeFms(“mesh.fms”) from the console at the bottom. The script is the standard OpenFOAM trisurf script to export the mesh as an FMS file, that I adapted so it is compatible with python 3.
I attached the script to this post.
salomeTriSurf.py (12.1 KB)
Well, I confirm the script works for me on Fedora 34 and Ubuntu 22 (with universal binaries and the new native Ubuntu 22 version).
I just had a warning with
smeshBuilder.New(salome.myStudy) that has to be replaced by
Do you launch Salome in a non-standard way?
have a look at this script for the exportation of salome meshes directly to OF format without the need of any other intermediate step GitHub - EastEriq/salomeToOpenFOAM: A python script that outputs a Salome mesh to OpenFOAM
Thank you guys for your help! Unfortunately, I need an FMS file because I am using CF-mesh+ for the volume meshing operation afterwards.
I have narrowed down the issue. The problem occurs when I set up my geometry in the shaper and then create multiple groups for different surfaces so that they later can be adressed in OF as patches.
When I create multiple groups in the shaper the issue occurs, however if I group all surfaces into just one group, the problem does not occur.
There is a workaround though. If I use the option “Export to GEOM” in shaper and then assign multiple groups in the geometry module, the export to FMS works again.
I really don’t understand what the issue is with assigning multiple groups in the shaper because this workflow was no problem in version 9.8.
Additionally, the error message is really misleading. Maybe that’s a bug in version 9.9 that should be fixed.
I have some questions if I may,
- you are using the scripts from this post no? A cfMesh workflow to speed up and improve your meshing – curiosityFluids
- you know that there is an OF utility for the creation of FMS files, from common meshes, it comes in the ESI version, and you can compile it for the fondation one (as it is part of the set of tools that comes with cfMesh, and cfMesh is not pre compiled for fondation); dont know the state for the foamExtended.
- If i remember correctly, cfMesh, FMS files are prefered but not obligatory, maybe giving a try without this.
- If I were you I would try with the universal linux distribution, if in that case does not work, you could dig more, but before breaking your head, try that.
Regarding your questions:
- Yes, this is exactly how I do it! Unfortunately, this scripts have not been updated and the scripts that come with the latest OF version are still not compatible with Python 3. So I converted them to Python 3.
- I haven’t heard about that tool before. Do you have the name of it or a link to the documentation so I can look it up?
- I have to look into that.
- Gotta do that next.
Thank you for your help!
For 2 and 3.
2. Here you have the link, OpenFOAM: Manual Pages: surfaceToFMS(1)
3. Pretty sure it is possible