Big scene - delete objects that aren't visible?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  04 April 2013
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?
__________________
----end of line
 
  04 April 2013
You can rectangle select the visible objects, invert and delete.
 
  04 April 2013
Originally Posted by Darter: 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


import c4d

def main():
    objlist  = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_CHIL  DREN)
    baseview = doc.GetActiveBaseDraw()
    
    doc.StartUndo()
    for obj in objlist:
        check(obj, baseview)
    doc.EndUndo()
    c4d.EventAdd()

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:
            lchild.append(cld)
    
    if not result["visible"] and not lchild:
        doc.AddUndo(c4d.UNDOTYPE_DELETE, obj)
        obj.Remove()
        return None
    
    elif not result["visible"] and lchild:
        parent = obj.GetUp()
        if not parent:
            parent = c4d.BaseObject(c4d.Onull)
        host   = c4d.BaseObject(c4d.Onull)
        host.SetName(obj.GetName())
        host.SetMl(obj.GetMl())
        host.InsertAfter(obj)
        
        for child in lchild:
            child.InsertUnderLast(host)
            
        doc.AddUndo(c4d.UNDOTYPE_DELETE, obj)
        obj.Remove()
        return host
    
    else:
        return obj

if __name__=='__main__':
    main()


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

http://codepad.org/miEhYxcf

Last edited by littledevil : 04 April 2013 at 05:25 AM.
 
  04 April 2013
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.
http://www.defcon-x.de/c4d/c4d-scripts

kind regards
mogh
__________________
R17 Visualize - Flickr Album - Website
 
  04 April 2013
Check the edit menu of the object list for inverting object selections
__________________
Matthew O'Neill
www.3dfluff.com
 
  04 April 2013
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)
__________________
----end of line
 
  04 April 2013
When I rectangle select in Object Mode, C4D selects everything. Not Just visible, whats wrong with my method?

kind regards
mogh
__________________
R17 Visualize - Flickr Album - Website
 
  04 April 2013
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 08:07 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.