Check if object is deleted from object browser in geomBuilder

Hello,
i have a list of objects, that I am publishing on the object browser, but then I delete one. is it possible to get a boolean flag for 1 or 0 if it was deleted from the object browser (manually on the GUI)?

eg.
g=[geompy.CreateGroup(compound, geompy.ShapeType[‘EDGE’]) for _ in gg]
disps=[geompy.addToStudyInFather( compound, group, str(nG)) for nG,group in enumerate(g)]
then in the GUI in the object browser select the object ‘1’ delete it and then do something like:
[group.GetStudyEntry() for group in g]
and get something like (where the element 1 is empty):
[‘0:1:1:45:169’, ‘’, ‘0:1:1:45:172’, ‘0:1:1:45:173’, ‘0:1:1:45:174’, ‘0:1:1:45:175’, ‘0:1:1:45:176’]
I dont care if it is empty/false or something in that realm, if i am able to distinguish that it has or not being deleted from the object browser.
dir(g[0]) did not give any method that looked like could work.

I would use:

isDeleted = salome.myStudy.FindObjectByPath('/Geometry/' + compound.GetName() + '/' + group.GetName() ) is None

to check if it is present. Maybe @fred has a better idea.

1 Like

thanks a lot @NabilG ,maybe not the cleanest but it does the job perfectly!
thanks a lot for the quick reply! this solves me a big issue that was quite anoying.

Hello @NabilG I am realizing that this is not working anymore for me, and not sure why.
I have on the geom object browser the following:

as you can see it has ‘Group_1’ and ‘defaultFaces’
then in python i am doing:

allGroups=geompy.GetGroups(compound_2ndGen)
#then if i list my objects (input for future findObjectByPath)
['/Geometry/' + compound_2ndGen.GetName() + '/' + group.GetName() for group in allGroups]
#i am getting the following output:
['/Geometry/compound_2ndGen/        group of blocks [BRICKS]', '/Geometry/compound_2ndGen/Quadrangle or Faux-quadrangle group', '/Geometry/compound_2ndGen/Propagation group [0]', '/Geometry/compound_2ndGen/Propagation group [1]', '/Geometry/compound_2ndGen/Propagation group [2]', '/Geometry/compound_2ndGen/        Propagation group [0] [DIRECTION 0]', '/Geometry/compound_2ndGen/        Propagation group [1] [DIRECTION 0]', '/Geometry/compound_2ndGen/        Propagation group [2] [DIRECTION 0]', '/Geometry/compound_2ndGen/        block [0] [BRICK]', '/Geometry/compound_2ndGen/Group_1', '/Geometry/compound_2ndGen/defaultFaces']
#nevertheless when I do:
[ salome.myStudy.FindObjectByPath('/Geometry/' + compound_2ndGen.GetName() + '/' + group.GetName() ) for group in allGroups]
#the output is the following
[<SALOMEDS._objref_SObject object at 0x710761aadf40>, <SALOMEDS._objref_SObject object at 0x71072ffdbd00>, <SALOMEDS._objref_SObject object at 0x71072ffdbf10>, <SALOMEDS._objref_SObject object at 0x710740023880>, <SALOMEDS._objref_SObject object at 0x710740243a60>, <SALOMEDS._objref_SObject object at 0x7107402430a0>, <SALOMEDS._objref_SObject object at 0x710740243250>, <SALOMEDS._objref_SObject object at 0x71072ffc7310>, <SALOMEDS._objref_SObject object at 0x71072ffc7640>, None, <SALOMEDS._objref_SObject object at 0x71072ffc7160>]

as you can see in the element [-2] of the last output the return of the list comprehension is None, where it should not be, as it exist in the object browser. the creation of the object Group_1 i am doing it during the python script to be precise it is too long and to complex to post it. I am missing something? or how could i do it?

to be more clear about this:
I am constructing programatically the specific groups, and I pause my script (wait for user input) where he/she can edit, for example the names of the current groups, create new ones and also delete the existing ones if desired, (by selecting a group and pressing supr key). once finished the user hits continue and the script follow up.
never the less, i want to recover all the groups on my object, so I am using the code that i posted here, but the allGroups will get not only the ones that are showing (including the newly created ones) but also the ones that where deleted. and I want to ensure myself that i am only keeping the ones that ‘ARE’ in the object broser, (so the newly created but not the ones deleted).