Loading existing hdf-files from within a python script

Hello,
I am having troubles with loading existing hdf-files from within a python script.
I am aware that this question has been posted here before a couple of times, but the answers given there do not work for me.
Briefly, what I intend to do is the following:
I wish to split my Salome workflow into sections that deal with geometry only, and mesh only, respectively. Ideally, I
- create a python file with geometry specifications;
- save the geometry, either manually or programmatically from within the script, as an hdf-file;
- load the hdf-file from within another python file that deals with mesh creation only.
- test_geom.py , which contains the geometry in terms of python commands;
- test_geom.hdf , which has been manually saved from within the GUI once test_geom.py has run through;
- test_mesh.py , which is the file I want to get working.
NameError: name 'Glue_1' is not defined .
Needless to say, the objects and their names are still there, fully contained in the hdf-file, as can be seen when the latter is loaded manually into the GUI via File > Open.
So what am I doing wrong?
Many thanks for your answer.
p, li { white-space: pre-wrap; }Re: Loading existing hdf-files from within a python script

Hi,
These objects do not exist in python memory. You can get them from the study with:
Glue_1 = salome.myStudy.FindObjectByPath("/Geometry/Glue_1").GetObject()
Face_1 = salome.myStudy.FindObjectByPath("/Geometry/Glue_1/Face_1").GetObject()
See updated test in attachment.
You could also have exported Glue_1 in XAO format at the end of your GEOM script and import it at the begin of your SMESH script.
Christophe
Re: Loading existing hdf-files from within a python script

Hi
This post explains how to get all geom objects of a study to python variables.
https://www.salome-platform.org/forum/forum_10/182599333/510129037
St.Michael
Hello Christophe,
many thanks for your quick reply.
I am sure that your method via FindObjectByPath will work. I have not tried it (yet), since, in the real-world cases I wish to apply the method to, I will have to deal with literally hundreds of geometry objects that must be recognized in the study. So the idea of including the same number of lines into my mesh scripts does not make me happy.
As for your second method, I didn't find a XAO format to export in my Salome - my version is 8.5.0, contained within Salome_meca 2018.0.
How can export into XAO format be done?
Many thanks,
Hanno
Previously Christophe Bourcier wrote:
Hi,
These objects do not exist in python memory. You can get them from the study with:
Glue_1 = salome.myStudy.FindObjectByPath("/Geometry/Glue_1").GetObject()
Face_1 = salome.myStudy.FindObjectByPath("/Geometry/Glue_1/Face_1").GetObject()See updated test in attachment.
You could also have exported Glue_1 in XAO format at the end of your GEOM script and import it at the begin of your SMESH script.
Christophe
Hi,
many thanks for your quick reply. I will try it out asap.
Hanno
Previously Saint Michael wrote:
Hi
This post explains how to get all geom objects of a study to python variables.
https://www.salome-platform.org/forum/forum_10/182599333/510129037
St.Michael