// =========================================================================== // 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. // =========================================================================== // // // Description: // This script is executed when the user wishes to have all selected strokes // share the same brush (that of the lead selection item). // // Creation Date: Dec 1998 // global proc string useSameBrush( ) { // No arguments. Takes selection list and makes all strokes // use the same brush - that of the primary/lead selection // object. // Returns the name of the brush all strokes were set to. string $strokes[] = `getStrokes 2`; string $stroke; int $idx = size( $strokes ); if ($idx == 0 || $strokes[$idx - 1] == "") { // No strokes are selected, do nothing. return ""; } string $leadNode = $strokes[$idx - 1]; string $theBrush = `connectionInfo -sourceFromDestination ($leadNode + ".brush")`; if ($theBrush == "") { // No brush or stroke node was found. warning ((uiRes("m_useSameBrush.kNoStrokes"))); return ""; } string $sourceAttr = $theBrush; for ($stroke in $strokes) { if ($stroke != $leadNode) { if (`nodeType $stroke` == "stroke") { string $attr = $stroke + ".brush"; string $result = `connectionInfo -sourceFromDestination $attr`; if( size($result) ) { string $buffer[]; int $num = `tokenize $result "." $buffer`; string $myBrush = $buffer[0]; if( ($myBrush + ".outBrush") != $sourceAttr ) { connectAttr -f $sourceAttr $attr; // We delete the existing brushes. delete $myBrush; } } else { connectAttr -f $sourceAttr $attr; } // Copy the pressure settings from the lead stroke. APP 23feb00 setAttr ($stroke + ".pressureMap1") `getAttr ($leadNode + ".pressureMap1")`; setAttr ($stroke + ".pressureMin1") `getAttr ($leadNode + ".pressureMin1")`; setAttr ($stroke + ".pressureMax1") `getAttr ($leadNode + ".pressureMax1")`; setAttr ($stroke + ".pressureMap2") `getAttr ($leadNode + ".pressureMap2")`; setAttr ($stroke + ".pressureMin2") `getAttr ($leadNode + ".pressureMin2")`; setAttr ($stroke + ".pressureMax2") `getAttr ($leadNode + ".pressureMax2")`; setAttr ($stroke + ".pressureMap3") `getAttr ($leadNode + ".pressureMap3")`; setAttr ($stroke + ".pressureMin3") `getAttr ($leadNode + ".pressureMin3")`; setAttr ($stroke + ".pressureMax3") `getAttr ($leadNode + ".pressureMax3")`; } // If it is not a stroke, ignore it. } // Else do nothing, it's the lead selection object. } return $theBrush; }