deleting a group with all its contents recursively

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
Post Reply
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

deleting a group with all its contents recursively

Post by bernd »

If I delete a group in the gui, I need to delete sometimes up to 5 times before all objects are really deleted. Is there a possibility to delete all group objects recursively?

bernd
drmacro
Veteran
Posts: 9001
Joined: Sun Mar 02, 2014 4:35 pm

Re: deleting a group with all its contents recursively

Post by drmacro »

Are you referring to a "group" object or a feature in the tree that has multiple features/operation under it?
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: deleting a group with all its contents recursively

Post by bernd »

a FreeCAD group object, especially the Arch spatial groups. They have groups in groups and Features in this groups and the python features are based on parts. sometimes a thousand or two thousand.
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: deleting a group with all its contents recursively

Post by bernd »

an example attached
Attachments
group_to_delete.FCStd
(315.59 KiB) Downloaded 43 times
chrisb
Veteran
Posts: 54288
Joined: Tue Mar 17, 2015 9:14 am

Re: deleting a group with all its contents recursively

Post by chrisb »

OPenSCAD->Remove objects and their children.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: deleting a group with all its contents recursively

Post by bernd »

chrisb wrote: Wed Jan 20, 2021 6:45 pm OPenSCAD->Remove objects and their children.
does not work on the group object from the file attache in my post before your post. If group object is selected the command is still grey
chrisb
Veteran
Posts: 54288
Joined: Tue Mar 17, 2015 9:14 am

Re: deleting a group with all its contents recursively

Post by chrisb »

Sorry, I had wrongly assumed it worked universally. :oops:
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: deleting a group with all its contents recursively

Post by bernd »

In the regard of openscad tool it is just a matter of implemented command activation. If a part object is added the command is not greyed and can be applied. It works than, but this is somehow cumbersome ...


group_to_delete2.FCStd
(315.44 KiB) Downloaded 19 times
chrisb
Veteran
Posts: 54288
Joined: Tue Mar 17, 2015 9:14 am

Re: deleting a group with all its contents recursively

Post by chrisb »

Good find! I had tried to move things into a normal group, but that didn't work either.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
keithsloan52
Veteran
Posts: 2764
Joined: Mon Feb 27, 2012 5:31 pm

Re: deleting a group with all its contents recursively

Post by keithsloan52 »

bernd wrote: Thu Jan 21, 2021 7:00 am In the regard of openscad tool it is just a matter of implemented command activation. If a part object is added the command is not greyed and can be applied. It works than, but this is somehow cumbersome ...

group_to_delete2.FCStd
I had a look at the code in the OpenSCAD workbench.

The relevant Feature is RemoveSubtree

Code: Select all

class RemoveSubtree:
    def IsActive(self):
        return FreeCADGui.Selection.countObjectsOfType('Part::Feature') > 0
        
    def Activated(self):
        print('Activated')
        import OpenSCADUtils,FreeCADGui
        OpenSCADUtils.removesubtree(FreeCADGui.Selection.getSelection())
Clearly the IsActive function is not going to find what I assume is an Object with a Group Type, only Part::Feature would current activate.
I tried adding a call to FreeCADGui.getSelection to the IsActive function, but clicking on the group does not cause this to return anything
and I did not see anything in the Selection View panel.
Post Reply