// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // // Creation Date: Oct 19, 1998 // // // // string objectLayer( string ) // // DAG displayLayer layer member // // // All eligible objects (ie. DAG objects) must be in exactly one layer. // This script returns the layer to which the given object belongs. // // // string $object // The name of the object who's layer is to be found. // // // // Create an object, which will automatically go into the defaultLayer // createNode transform -n father; // objectLayer father; // // Result : defaultLayer // // // // Put the object into a layer and verify membership // createDisplayLayer -e -n fatherLayer; // editDisplayLayerMembers fatherLayer father; // objectLayer father; // // Result : fatherLayer // // // // The time node is not a DAG node and so has no layer // objectLayer time1; // // // The above blank line indicates that there was no return value // // // string: The layer the object belongs to. NULL if the object is // not eligible for layer membership. // // global proc string objectLayer(string $object) { // First determine that the object is a legal layer member. string $drawOvr = ($object + ".drawOverride"); if( ! `objExists $drawOvr` ) { return ""; } // Now look across the draw override connection to find the layer it // belongs to. string $connList[] = `listConnections -t displayLayer -d false $drawOvr`; if( size($connList) == 1 ) { return $connList[0]; } return "defaultLayer"; }