Form and Space

creating CG 3D since 2001

  • Connect @
  • Linked in
  • Vimeo
  • Twitter

Create Named Layers

Matthew | October 1, 2014

No Comments

I needed this today to make a lot of layers from a selection. Select objects and run this global script, and get layers for each selection. If the selection has children, they are added to the parents layer. See the comments for more info.

global proc mls_makeNamedLayer()
    string $sel[] = `ls -sl`;
    int $cnt = size($sel);
    if($cnt < 1)
        error "Select object(s) first.";
    for($i=0; $i<$cnt; $i++)
        select -r $sel[$i];
        // use -nr flag to force only selected object
        // be on the new display layer, otherwise add
        // all the children, too.
        createDisplayLayer -name ($sel[$i] + "_lyr") -number ($i+1);

Leave a Reply