Personal tools
You are here: Home Forum Use delete an entire mesh and an entire geometry

delete an entire mesh and an entire geometry

Up to Use

delete an entire mesh and an entire geometry

Posted by josef roider at August 22. 2011

Hello,

I am wondering if there is a python command which can delete the mesh and the geometry similarly like selecting an element and clicking on the right mouse button -> delete.

I am looking for a function to delete the entire structural element 'MyRoof' in my study (and its corresponding mesh). It is ideally used somewhat like:

geompy.DeleteGeometry(MyRoof) and geompy.DeleteMesh(MyRoofMesh), respectively.

Is there a python function to do this?

Josef

 

Re: delete an entire mesh and an entire geometry

Posted by Saint Michael at August 24. 2011

Hello Josef

AFAIK you can only delete any object from the study this way

studyObject = salome.myStudy.FindObjectIOR( salome.myStudy.ConvertObjectToIOR( objToRemove ))
aStudyBuilder = salome.myStudy.NewBuilder()
if studyObject: aStudyBuilder.RemoveObjectWithChildren( studyObject )

Regards
St.Michael

Re: delete an entire mesh and an entire geometry

Posted by josef roider at August 24. 2011

Thank you St.Michael, it helped a lot for finding the solution.

I actually succeeded with:

 

myStd = salome.myStudy

obj = myStd.FindObjectByName("RoofMesh","SMESH")   # RoofMesh is the mesh name -> list of objects

myStudyBuilder = myStd.NewBuilder()

myStudyBuilder.RemoveObjectWithChildren(obj[0])          #select an object from the list

salome.sg.updateObjBrowser(0)                                       #update the GUI

 

Regards

,

josef

Re: delete an entire mesh and an entire geometry

Posted by Vladimir Glavny at April 22. 2014

Hello,

How to delete ALL objects in current geometry, using python?

I need a command like "Clear All". It useful for script's debugging.

Regards,
Vladimir

Re: delete an entire mesh and an entire geometry

Posted by Saint Michael at April 23. 2014

Hi Vladimir

The following code removes all in both SMESH and GEOM

        for compName in ["SMESH", "GEOM"]:
                comp = salome.myStudy.FindComponent(compName)
                if comp:
                        iterator = salome.myStudy.NewChildIterator( comp )
                        while iterator.More():
                                sobj = iterator.Value()
                                iterator.Next()
                                nb.RemoveObjectWithChildren( sobj )

St.Michael

Re: delete an entire mesh and an entire geometry

Posted by Konyaro at April 27. 2020

Hello,

Thank you St.Michael, I've been using your method for a long time. I want to do the same with Shaper but adding SHAPER in:

 for compName in ["SMESH", "GEOM", "SHAPER"]:

does not return an error but doesn't remove the parts. Do you have another trick to clear the shaper module?

Best regards,

Konyaro

Re: delete an entire mesh and an entire geometry

Posted by Saint Michael at April 27. 2020

Hi Konyaro

Unfortunately I don't know SHAPER well enough yet to do that :(

St.Michael

Re: delete an entire mesh and an entire geometry

Posted by Konyaro at April 28. 2020

Thank you St. Michael for your answer. I will let your know if I find a solution.

Regards,

Konyaro

Powered by Ploneboard
Document Actions