Personal tools
You are here: Home Forum Use Deleting objects from the study using TUI [UnRegister?]

Deleting objects from the study using TUI [UnRegister?]

Up to Use

Deleting objects from the study using TUI [UnRegister?]

Posted by ppeetteerr at March 21. 2012

I am running a loop inside of Salome and would like to free up the memory by destroying the objects before starting the next loop. However, I don't seam to be able to get UnRegister to work. I create the geometry add it to study and then attempt to remove it but it is still there. Any suggetions? Also how do I do this with a mesh?

 

import geompy

Vertex_1 = geompy.MakeVertex(0, 0, 0)

geompy.addToStudy( Vertex_1, 'Vertex_1' )

Vertex_2 = geompy.MakeVertex(0, 2, 0)

geompy.addToStudy( Vertex_2, 'Vertex_2' )

Vertex_1.UnRegister()

 

 

Attachments

Re: Deleting objects from the study using TUI [UnRegister?]

Posted by Saint Michael at March 22. 2012

You can remove a GEOM object this way:

    so = salome.ObjectToSObject(shape)
    sb = salome.myStudy.NewBuilder()
    sb.RemoveObjectWithChildren( so )
    geompy.GEOM._objref_GEOM_Gen.RemoveObject(geompy.geom, shape)

The last command is so complex because in GEOM there are two functions
RemoveObject(), one removes a sub-object from a group, the other
removes an object from the current study. The first function overrides the
latter and the last command reaches the hidden function.

In SMESH:

    meshSO = salome.ObjectToSObject(mesh.GetMesh())
    sb = salome.myStudy.NewBuilder()
    sb.RemoveObjectWithChildren( meshSO )
    mesh.Clear() # just in case
    mesh.mesh.UnRegister()

Powered by Ploneboard
Document Actions