|04 April 2009||#1|
3D Modeler, Rigger and Animator
Rio de Janeiro, BR
How do I sort a list of objects by creation order
I want to select all my objects ending on *_bs, but I need the list to be ordered by creation... so the last object created ending itts name on "_bs" to be the last in the list.
Thanx for any help.
|04 April 2009||#2|
London, United Kingdom
I don't believe maya stores this information so you have no real way of knowing. The only semi-reliable way I can think of is to read in the maya ascii file line by line, and sort based on what order you encounter the createNode commnads for the nodes you are interested in.
|04 April 2009||#3|
The Monument House/Balls n Knuckles LLC
Maya Ascii will not work... nodes are saved by order ( in the outliner )
You could use the reorder command to reflect creation order but that could be limiting if you needed to parent with a different ordering strategy.
With a new scene, starting from scratch ( that hasn't been saved since creating objects )
Then all u need is `ls` or `ls -o`
( `ls -tr` and `ls -g` will return alphabetically. ls -sl used with these variation's will return in selection order )
You can re-order all you want but the code will always return in creation order.
Till you hit save. ( not very useful )
You need yer own "object creation order builder" and bind it to yer scene.
( have builder survive saves and save as. )
the event "DagObjectCreated" will allow for a scriptjob to trigger when an object is created ( mostly ) duplicated or undone from deletion.
In this way you can record object creation. ( from proc executed by the scriptJob )
"Some" of the the new primitive creation tools will not trigger on "DagObjectCreated".
However the event "ToolChanged" can be used to cover for those intances.
A third scriptJob could be used to handle subtracting deleted objects with the condition true "delete".
Storage of this dynamic array could be done many ways ( to file, to Ui, optionVar etc... )
A script node could be used. Not only to bind the scriptJobs to your scene but could also double as
the storage for the object order. ( dynamically build an attr list that reflects object order )
( note: the template here doesn't solve for renaming, object paths and name clashing )
first proc to create the object order node ( ideally executed at first stages of scene build )
to make long names legal as attr names u could use a while | subtitute _ loop or jes use the attr's
-at flag as "string" and store there
second proc of Jobs called by the object order script node
( scriptJobs to dynamically build and destroy the array of attr order )
( attr order reflects object order )
now u can return the stored object order at anytime with the following command:
Also... as undo from an object delete will also trigger "DagObjectCreated" the undone deleted object will now be last in order. ( a way to manually re-order? or an inconsistency? )
If an iconsistency. fix it with ( a deleteUndo conditionTrue )
|04 April 2009||#4|
Thread automatically closed
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
|Thread Closed share thread|