Open HDF file from python file???
Open HDF file from python file???Posted by Fabio Furlan at November 19. 2012
for an Optimization loop I need to open hdf file from python file. What is the command please? I just tried the command
study = salome.myStudyManager.OpenStudy("/home/user/MyStudy.hdf")
but it doesn't work.
Thank you all for the time and consideration.
Re: Open HDF file from python file???Posted by SMESH/MED expert at November 19. 2012
I usually use such code to open a study and then use SMESH commands on it
salome.myStudy = salome.myStudyManager.Open( file_name )
salome.myStudyId = salome.myStudy._get_StudyId()
salome.myStudyName = salome.myStudy._get_Name()
meshCompSO = salome.myStudy.FindComponent("SMESH")
b = salome.myStudy.NewBuilder()
b.LoadWith( meshCompSO, smesh.smesh )
Re: Open HDF file from python file???Posted by William Tougeron at November 19. 2012
I don't know on Windows, but on Linux, I simply type:
in a console and Salome loads automatically the HDF file after opening.
So, maybe you could just use a "os.system" command to do it from your Python script:
fileName = "Study1.hdf"
os.system( "salome " + fileName )
I hope it's what you were looking for.
PS: My "salome" command is an alias of:
I installed my Salome version into my /opt/salome/ folder, but on your computer (or server), it can be different, of course
Re: Open HDF file from python file???Posted by Fabio Furlan at November 21. 2012
Thanks for the replies. It finally works. Another question: I create a compound mesh (call compound_mesh) and I have to extrude it (from python file) and export it (in UNV format, from python file too). How can I do it?
Re: Open HDF file from python file???Posted by Saint Michael at November 21. 2012
## Generates new elements by extrusion of the elements which belong to the object
# @param theObject the object which elements should be processed.
# It can be a mesh, a sub mesh or a group.
# @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
# @param NbOfSteps the number of steps
# @param MakeGroups forces the generation of new groups from existing ones
# @param IsNodes is True if elements which belong to the object are nodes
# @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
# @ingroup l2_modif_extrurev
def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False, IsNodes=False):
## Exports the mesh in a file in UNV format
# @param f the file name
# @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
# @ingroup l2_impexp
def ExportUNV(self, f, meshPart=None):