Impossible to "really" delete geometrical groups in the GUI when created from script
Impossible to "really" delete geometrical groups in the GUI when created from scriptPosted by William Tougeron at November 02. 2012
Since I am on the forum, I would like to speak of a problem I have which is very specific but important for my work.
It is about group creation and deletion in the Geometry module. Actually, when I create a geometrical group on an object from the GUI and if I delete this group always from the GUI, it really disappears. I mean: if I demand to display the groups of this objects in a Python script, the group is not here anymore.
But if I create a group in a script with the method I saw in the documentation:
- geompy.CreateGroup() # Create the group
- geompy.AddObject() # Add IDs to the group
- geompy.addToStudyInFather() # Add the group to the study tree
And then if I delete the group in the GUI, it disappears from the study tree... but still exists "somewhere" so that if I try to find it in a Python script I will!
This is a problem because I want to develop user-friendly Python functions to be use in the Python console of Salome and dealing with groups... But if a user deletes a group created with one of my functions, then creates another group with the same name and try to use a function on it by giving its name, the function will find the old one being deleted and not the new one...
If someone has an idea...
Enclosed is a Python script to use on a geometrical object called "Box_1". Just create this "Box_1", then create some groups on it in the GUI. Then you can launch the script. It will add a new group with a random name, then will display the groups found in the box. You can launch it, then try to delete some handmade groups and launch it again. You will see that the deleted groups won't appear in the found group list. But if you delete "python-created" groups, you will see that they will always be found by the script during the following launches.
This problem occurs with my 5.1.5 and 6.5.0 versions of Salome.
Re: Impossible to "really" delete geometrical groups in the GUI when created from scriptPosted by Christophe Bourcier at November 05. 2012
You can use deleteShape from GeomStudyTools to completly delete a shape.
See the attached script, and the documentation http://docs.salome-platform.org/salome_6_5_0/tui/GEOM/docutils/docapi.html#salome.geom.geomtools.GeomStudyTools.deleteShape