Sort by Object Name

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
Old 08 August 2012   #1
Sort by Object Name

Is there any way or a plugin that can help sort objects in the Object Manager alphabetically?

I have some files with hundreds of objects, all clearly named, but scattered all over the list. I would like to group these by name, but manually sorting them is taking an age. I expect to receive more files as the project develops and can see it becoming a repetitive and time consuming task.

Many thanks

alawrence
 
Old 08 August 2012   #2
i know nothing about a ascript like this. but maybe the magnifying glass symbol on the top of the object manager can help you. its a searchbox. and if you are searching for different object types the eye symbol can help.

best regards
Jops
 
Old 08 August 2012   #3
...someone was faster :-)

br, Lubo
Attached Images
File Type: jpg OM.jpg (96.5 KB, 120 views)
 
Old 08 August 2012   #4
Thanks

Good ideas.

These are both a bit manual and time consuming. I was hoping for something more automated.
 
Old 08 August 2012   #5
See if this helps.
For use in Python ScriptsManager.


# SORT OBJECTS ALPHABETICALLY IN OM
import c4d
from c4d import gui

def main():
    obj = doc.GetFirstObject()
    if not obj: return True
    doc.StartUndo()
    olist = []
    while obj:
        olist.append([obj.GetName(),obj])
        obj = obj.GetNext()
    
    olist.sort()
    olist.reverse()
    
    for i,o in enumerate(olist):
        doc.AddUndo(c4d.UNDOTYPE_CHANGE,o[1])
        o[1].Remove()
        doc.InsertObject(o[1],None,None)

    c4d.EventAdd()
    doc.EndUndo()

if __name__=='__main__':
    main()


Cheers
Lennart
__________________
MSA | OSX | xfiles ...Cinema4D Tools
 
Old 08 August 2012   #6
It's possible if you switch to the flat tree view of the OM. Enable "Flat Tree" and "Sort by Name".
Attached Images
File Type: png sort_by_name.png (22.0 KB, 66 views)
__________________
http://www.bobtronic.com
 
Old 08 August 2012   #7
Many Thanks Bobtronic and Tcastudios

Many Thanks Bobtronic and Tcastudios

I have a few options to try now.

Thanks guys
 
Old 08 August 2012   #8
Improvements

Hello Lenart

Many thanks for your script. I can get it to work in V13 but not V11. (client still using V11 unfortunately)

This is the first time I have used a python script.Unfortunately it is well above my intelligence.

Would it be possible to extend the function of your script to group the objects under a null of the same name as the objects.

I can see really potential lifesaver for me and I could see myself using this everyday. I just love the order it brings to the files.

Best regards

alawrence

Last edited by alawrence : 08 August 2012 at 02:00 PM.
 
Old 08 August 2012   #9
By me, pre R12, will not happen (someone with time would have to make it in COFFEE) and extended functionality, not any time soon I'm afraid.
But the code is open for anyone else to extend.

Cheers
Lennart
__________________
MSA | OSX | xfiles ...Cinema4D Tools
 
Old 01 January 2013   #10
Hi tcastudios,

I'm trying to use your sorting script but unfortunately I'm a total noob when it comes to this stuff. How do I use it? I pasted the code into the python script editor and click on 'execute' but nothing happens. Is this all I have to do?
I find the need for sorting objects (without going to flat tree) a big necessity. I cant believe that Cinema cannot do that ... I'm using R14 Studio.
Can you help?
Thanks

Last edited by palosanto : 01 January 2013 at 09:13 PM.
 
Old 01 January 2013   #11
Check your indents, typically 1 Tab or 4 spaces per indent.
Copy paste can be faulty, make sure you are using a
real text editor handling plain text, no formatting.

Cheers
Lennart
__________________
MSA | OSX | xfiles ...Cinema4D Tools
 
Old 01 January 2013   #12
Hi again,
Thanks for the quick reply.
Everything seems ok but still no joy ... :(
Can you see anything? I imagine that clicking on execute or running it from the menu "user script/run script" should do the same . The file is a plain text file and it loaded like the image

 
Old 01 January 2013   #13
As I said, you need to examine it in a text editor
and check the "invisibles" for any mismatching.

Any line break must be clean all tab intends must
also be clean.

The Console should tell at what line(s) there are issues.

Cheers
Lennart
__________________
MSA | OSX | xfiles ...Cinema4D Tools
 
Old 01 January 2013   #14
Nope. No errors. No sorting ....
I tried also in R13 ... nothing.

I must be doing something basically wrong. Where can I find a super simple script to try and see whether is the script or my system?
Sorry to keep bothering you. Thanks for your patience
Juan
 
Old 01 January 2013   #15
Then type it instead of CopyPaste.
Else, no clue.

Cheers
Lennart
__________________
MSA | OSX | xfiles ...Cinema4D Tools
 
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 12:22 PM.


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