// =========================================================================== // 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: 23 April 2001 // // Procedure Name: // art3dPaintEffectsBrushCallback // // Description: // Callback that is called via a scriptJob whenever an important // attribute on the paint effects default brush is changed. // // Input Arguments: // $artCommand - command to change tool settings // // Return Value: // None. // global proc art3dPaintEffectsBrushCallback( string $artCommand ) { // Set the paint effects brush mode. // string $currContext = `currentCtx`; if ( $currContext != "art3dPaintContext" ) return; // Read old values out of the context to see if we really need to update it // string $cmd = $artCommand + " -q -paintoperationtype " + $currContext; string $oldOp = eval( $cmd ); $cmd = $artCommand + " -q -brushtype " + $currContext; string $oldBrushType = eval( $cmd ); $cmd = $artCommand + " -q -pfxScale " + $currContext; float $oldScale = eval( $cmd ); $cmd = $artCommand + " -q -pfxWidth " + $currContext; float $oldWidth = eval( $cmd ); // If 3D paint is not in paint effects mode, then we don't need to update // if ( $oldBrushType != "effectsBrush" ) return; // Figure out the new values to set into the context // string $operation; float $scale, $width; // Set the paint mode based on the brush settings // string $defaultBrush = getDefaultBrush(); int $mode = getAttr( $defaultBrush + ".brushType" ); switch( $mode ) { case 0: // Paint case 4: // ThinLine case 5: // Mesh $operation = "Paint"; break; case 1: // Smear $operation = "Smear"; break; case 2: // Blur $operation = "Blur"; break; } $scale = getAttr( $defaultBrush + ".globalScale" ); $width = getAttr( $defaultBrush + ".brushWidth" ); // Check to see if we need to update the context // if ( ( $oldOp == $operation ) && ( abs( $oldScale - $scale ) < 0.0001 ) && ( abs( $oldWidth - $width ) < 0.0001 ) ) { // Everything's up to date // return; } // Build and execute the command to update the context // $cmd = $artCommand; $cmd += " -e -paintoperationtype \"" + $operation + "\" "; $cmd += " -e -pfxScale " + $scale + " "; $cmd += " -e -pfxWidth " + $width + " "; $cmd += $currContext; eval $cmd; }