// =========================================================================== // 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: 18 May 2005 // // // // // // int renderLayerParent( string $parent, string $child ) // // // int : 1 if render layer parenting was successful, 0 otherwise. // // // This procedure causes render layer node $child to become contained // within render layer node $parent via a layer hierarcy relationship. // Containment is implemented by connecting the render layer hierarchy // attributes on the two nodes as appropriate. There are certain // conditions which are not permitted, such as a cyclic relationship, // instancing within a layer hierarchy, attempting to connect to the // default layer, etc. Any invalid conitions will trigger an error // message and 0 will be returned. // // See also renderLayerUnparent(). // // // string $parent The render layer node we want to be the parent. // string $child The render layer node we want to be the child. // // // // Create two render layer nodes. // // // string $parent = `createRenderLayer -name "parent" -empty`; // string $child = `createRenderLayer -name "child" -empty`; // // // Make "parent" contain "child". // // // int $status = renderLayerParent( $parent, $child ); // // // global proc int renderLayerParent( string $parent, string $child ) { int $status = 1; // Remember the current render layer node. Select the default render // layer. This restores any previous adjustments. // string $current = `editRenderLayerGlobals -q -currentRenderLayer`; if(catch(`editRenderLayerGlobals -currentRenderLayer "defaultRenderLayer"`)) { $status = 0; } // Now try to perform the parenting operation. This will internally // check that the nodes are both render layers, and there is no // cycle, etc. An error is issued if anything is wrong. // string $cmd = "connectAttr -na "+$child+".rlp "+$parent+".rlc;"; if ( catch( eval( $cmd ) ) ) { $status = 0; } // Make the previous render layer current again. This sets any // adjustments. // if(catch(`editRenderLayerGlobals -currentRenderLayer $current`)) { $status = 0; } return( $status ); }