// =========================================================================== // 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. // =========================================================================== // groupReference.mel // // Callback to be used when loading a reference // Assumes top level nodes in reference are selected when this script is called, // groups top level nodes in file and adds message connection // global proc string groupReference (string $refNode, string $grpName ) { string $actualGrpName = $grpName; if( size($actualGrpName) == 0 ) { $actualGrpName = $refNode + "group"; } // if this is a reference just create a transform node for future use // we will parent the nodes to it later (each time we load the reaferece) // but if we're importing (no reference node supplied), group now string $grpNode; if(size( $refNode ) > 0) { $grpNode = `createNode transform -n $actualGrpName`; //Indexes on the associatedNode attribute are used to make specific associations, index 0 is reserved for the group node. connectAttr ($grpNode+".message") ($refNode + ".associatedNode[0]"); select -r $grpNode; } else { if ( size(`ls -sl`) > 0 ) { // The group command displays an in-view message that we don't want displayed. string $ivmEnableStr = "inViewMessageStatusEnable"; int $ivmEnable = `optionVar -q $ivmEnableStr`; if ($ivmEnable) optionVar -iv $ivmEnableStr false; catch($grpNode = `group -w -n $actualGrpName`); if ($ivmEnable) optionVar -iv $ivmEnableStr true; xform -cp $grpNode; select -r $grpNode; } } return $grpNode; }