// =========================================================================== // 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. // =========================================================================== // groupLocatorReference.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 with a locator and annotation // indicating the reference node // global proc string groupLocatorReference (string $refNode, string $grpName ) { // if there is a non empty group name, then exactly that name is used // otherwise we use the reference node name with the "group" suffix // the other nodes still get their node types tacked on in eityher case string $actualName = $grpName; string $actualGrpName = $grpName; if( size($actualName) == 0 ) { $actualName = $refNode; $actualGrpName = $refNode + "group"; } string $actualLocName = $actualName + "locatorShape"; string $grpNode = `createNode transform -n $actualGrpName`; string $locNode = `createNode locator -n $actualLocName`; string $locParent[] = `listRelatives -parent $locNode`; string $grpNames[] = `parent $grpNode $locParent[0]`; // Indexes on the associatedNode attribute are used to make specific associations, // index 0 is reserved for the group node, // index 1 is reserved for the locator node. connectAttr ($grpNames[0] + ".message") ($refNode+".associatedNode[0]"); connectAttr ($locParent[0]+ ".message") ($refNode+".associatedNode[1]"); select -r $locParent[0]; return $locNode; }