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)
# This script conditionally removes objects from the scene.
# 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 WalkObjects(obj, cond, do):
while obj is not None:
objNext = obj.GetNext()
if obj.GetDown() is not None:
WalkObjects(obj.GetDown(), cond, do)
obj = objNext
obj = doc.GetFirstObject()
WalkObjects(obj, Condition, DoRemove)
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.