Big scene - delete objects that aren't visible?


I have big heavy scene loaded up from a modeler friend. However, only a part of it is visible in this one shot I’m working on.

Is there any automagical way to delete objects that aren’t visible in the camera view?


You can rectangle select the visible objects, invert and delete.


i might be wrong, but i do not think that there is an option to invert object selections.
you can only invert point, edge, uv and polygon selections imho. however even if you
you could (by writing a small script) you would run into a problem regarding objects
nesting other objects. the dimension of an object is defined by the objects it is hosting.
so if a null hosts two objects, objA which is on screen and objB is off screen, the null will
range from on to off screen and therefore won’t be selected by the rectangle tool as it
does not offer a tolerant option for object selections. inverting the selection then will
select the null and also delete the object which is on screen.

long story short, here is a small script which tries to avoid the whole problem. it does
work selection and viewport based. so you have to select all parent objects which you
want to be included into the operation. you also have to make the viewport active (this
tiny white border) which is supposed to be the testing viewport.

haven’t tested it very extensively, just wrote it from scratch because i liked the problem.
so there might be some problems i have overlooked. i might fix them later or someone else
will help you :wink:

import c4d

def main():
    objlist  = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_CHILDREN)
    baseview = doc.GetActiveBaseDraw()
    for obj in objlist:
        check(obj, baseview)

def check(obj, bv):
    result = bv.TestClipping3D(c4d.Vector(), obj.GetRad(), obj.GetMg())
    lchild = []
    for child in obj.GetChildren():
        cld = check(child, bv)
        if cld:
    if not result["visible"] and not lchild:
        doc.AddUndo(c4d.UNDOTYPE_DELETE, obj)
        return None
    elif not result["visible"] and lchild:
        parent = obj.GetUp()
        if not parent:
            parent = c4d.BaseObject(c4d.Onull)
        host   = c4d.BaseObject(c4d.Onull)
        for child in lchild:
        doc.AddUndo(c4d.UNDOTYPE_DELETE, obj)
        return host
        return obj

if __name__=='__main__':

as the board is most likely going to mess up the code somewhere, here is a codepad


I’ve been working on something similar, but stumpled over my own stubbornes.

Anyway the script is working and putting Polygon Objects on a Layer which are blocked by other objects. Its Probably not the best solution for your scene hence you will not only have poly objects and you have ony one view.

So this is just for the people searching a similar problem.

The Brute Force Exclusion script is at the bottom of the page.

kind regards


Check the edit menu of the object list for inverting object selections


Thanks for the responses.

I think I’ve found a way that works for me. As suggested, I rectangle select everything visible in the camera view. Then in the Object Manager, use Edit > Invert Selection.

Then use Delete Without Children command. (This is the crucial step, otherwise I ended up deleting objects that were buried in groups)


When I rectangle select in Object Mode, C4D selects everything. Not Just visible, whats wrong with my method?

kind regards


This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.