So, here you go.
Simply load or (better import) the attached script into the Script Manager.
Regarding my above question, see lines five and six of the script.
As it is now (line 6 commented) it will delete only selected objects with editor visibility off.
If you uncomment line 6, it will delete all objects with editor visibility off.
NOTE: In current state the script will only pay attention to the selection state of objects in the first Object Manager. (as Cairyn pointed out below, all Object Managers share the same object selection)
delete_objects.py (849 Bytes)
Cheers
# This script conditionally removes objects from the scene.
import c4d
# Set the condition for removal
# Choose a line or add a new one yourself:
Condition = lambda o: o[c4d.ID_BASEOBJECT_VISIBILITY_EDITOR] == 1 and o.GetBit(c4d.BIT_ACTIVE) == True
#Condition = lambda o: o[c4d.ID_BASEOBJECT_VISIBILITY_EDITOR] == 1
def DoRemove(obj):
doc.AddUndo(c4d.UNDOTYPE_DELETE, obj)
obj.Remove()
def WalkObjects(obj, cond, do):
while obj is not None:
objNext = obj.GetNext()
if obj.GetDown() is not None:
WalkObjects(obj.GetDown(), cond, do)
if cond(obj):
do(obj)
obj = objNext
def main():
obj = doc.GetFirstObject()
doc.StartUndo()
WalkObjects(obj, Condition, DoRemove)
doc.EndUndo()
c4d.EventAdd()
if __name__=='__main__':
main()
EDIT: As Cairyn pointed out, the first version posted here, was a pile of dinosaur poo. I fixed it in this post, not so much to hide my incompetence, but rather to avoid a future reader grabbing a broken version.