// =========================================================================== // 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. // =========================================================================== global proc polyLaunchPaintReduceTool() // // Description: // A convenience procedure for launching the paint reduce weights tool. // { // Sometimes when the paint tool is launched from the Edit Polygons menu // the artAttrCreateMenuItems.mel file has not been sourced. Do it now // to make sure we execut artSetToolAndSelectAttr. // if (`whatIs artSetToolAndSelectAttr` == "Unknown" ) { source artAttrCreateMenuItems.mel; } string $selectWarn = (uiRes("m_polyLaunchPaintReduceTool.kReducePaintNoNodeWarning")); // Check selection list validity // string $sel[] = `ls -sl`; if ( size( $sel ) == 0 ) { warning $selectWarn; return; } if ( size( $sel ) > 1 ) { warning((uiRes("m_polyLaunchPaintReduceTool.kReducePaintTooManyWarning"))); } // Try to find a reduce node. Look downstream first. // string $nodes[] = `listHistory -future true $sel[0]`; string $node = ""; string $target = ""; for ($node in $nodes) { if ( "polyReduce" == `nodeType $node` ) { $target = $node; break; } } // If no reduce node is found downstream, try upstream. // if ( "" == $target ) { $nodes = `listHistory -future false $sel[0]`; for ($node in $nodes) { if ( "polyReduce" == `nodeType $node` ) { $target = $node; break; } } } // If we still haven't found a reduce node, then the selection isn't // paintable. // if ( "" == $target ) { warning $selectWarn; return; } artSetToolAndSelectAttr( "artAttrCtx", "polyReduce." + $target + ".vertexWeights" ); }