Script To Auto Sort "high" and "low" suffix into "high" and "low" Layers?

Script To Auto Sort "high" and "low" suffix into "high" and "low" Layers?

louis.clegg
Observer Observer
831 Views
1 Reply
Message 1 of 2

Script To Auto Sort "high" and "low" suffix into "high" and "low" Layers?

louis.clegg
Observer
Observer

Hi All, 


I've no idea how to write scripts but I think this might be a tool that would be useful to a lot of people, that doesn't appear to already exist. So I'm hoping some kind souls out there my help me with a script that would, at the click of a button, sort all objects with a "high" or "low" suffix into an equivalent "high"and "low" layer. Is this easy enough to achieve and can anyone help me out?

 

Cheers,
Louis


EDIT: I may not be able to auto sort but I can select my high groups and add them to a named layer with 
layerEditorAddObjects layerName;

and that will at least do the job I need.

0 Likes
832 Views
1 Reply
Reply (1)
Message 2 of 2

trs_andre
Collaborator
Collaborator

Hi!

In case you still need the script, here it is (MEL and Python).

Please comment the first two lines if the layers already exist.

 

createDisplayLayer -noRecurse -name "high";
createDisplayLayer -noRecurse -name "low";

select `ls "*low"`;
editDisplayLayerMembers -noRecurse low `ls -sl`;

select `ls "*high"`;
editDisplayLayerMembers -noRecurse high `ls -sl`;

select -cl;
import pymel.core as pm
pm.createDisplayLayer(noRecurse=1, name="high") pm.createDisplayLayer(noRecurse=1, name="low")
pm.select(pm.ls("*low")) pm.editDisplayLayerMembers('low', pm.ls(sl=1), noRecurse=1)
pm.select(pm.ls("*high")) pm.editDisplayLayerMembers('high', pm.ls(sl=1), noRecurse=1)
pm.select(cl=1)

André Moreira

Game Developer / Technical Artist

LinkedIn

0 Likes