// =========================================================================== // 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. // =========================================================================== // // Procedure Name: // copyAttrValuesMain // // Description: // This procedure copies attr values from the source node to the // destination node. // // Input Arguments: // string $objList[]: list of objects - source first, then destination items // string $attrList[]: list of attrs to copy // // Return Value: // None. // global proc copyAttrValuesMain( string $objList[], string $attrList[] ){ string $objSource = $objList[0]; string $objDest; int $i; string $attr; for ($attr in $attrList){ $value = `getAttr ($objSource + "." + $attr)`; for ($i=1; $i < size($objList); $i++) { $objDest = $objList[$i]; catch(`setAttr ($objDest + "." + $attr) $value`); string $dest = `connectionInfo -ged ($objSource + "." + $attr)`; if ($dest != ""){ string $tokens[]; clear $tokens; int $num = `tokenize $dest "." $tokens`; $newDest = ($objDest + "." + $tokens[1]); $source = `connectionInfo -sfd ($objSource + "." + $attr)`; if ($source != "" && $dest != "") {catch(`connectAttr $source $newDest`);} } } } } // // Procedure Name: // copyAttrValues // // Description: // This procedure gets the selected channels from the channelBox. It then // sends those lists to copyAttrValuesMain for copying the selected // attribute values between nodes. // // -select at least 2 objects, source object last (so // you can see it's attributes in the channelBox) // -highlight attributes to copy in the channelBox // -run script // // This script currently only copies connections - it // does not duplicate the upstream nodes. // // Input Arguments: // None // // Return Value: // None. // global proc copyAttrValues(){ // process selected objects string $objList[] = `channelBox -q -mainObjectList mainChannelBox`; string $attrList[] = `channelBox -q -selectedMainAttributes mainChannelBox`; copyAttrValuesMain $objList $attrList; // now process history nodes $attrList = `channelBox -q -selectedHistoryAttributes mainChannelBox`; $objList = `channelBox -q -historyObjectList mainChannelBox`; copyAttrValuesMain $objList $attrList; }