Personal tools
You are here: Home Forum Use Python function for getting a list of all the submesh

Python function for getting a list of all the submesh

Up to Use

Python function for getting a list of all the submesh

Posted by Moise Rousseau at October 10. 2019

Hi all !

I would like to know if these is a python function for getting a list of all the submesh of a mesh object. A work around is to get the submesh order with the method "GetMeshOrder" but the returned list is empty when there is no comflit between submeshes. I read the SMESH Python doc without finding a function for my need.

Thanks for your help,

Moise

Re: Python function for getting a list of all the submesh

Posted by Saint Michael at October 10. 2019

Hi Moise

You can find sub-meshes by iterating all sub-object of your mesh in the study tree. Here is the code doing it:

so = salome.myStudy.FindObjectByPath("/Mesh/__NAME_OF_YOUR_MESH___")
if so:
    it = salome.myStudy.NewChildIterator( so )
    it.InitEx(True)
    while it.More():
        so = it.Value()
        it.Next()
        obj = so.GetObject()
        if isinstance( obj, SMESH._objref_SMESH_subMesh):
            print ( so.GetName())

 

St.Michael

Powered by Ploneboard
Document Actions