// =========================================================================== // 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 polyReFormSetTool() { if ( `currentCtx` == "polyReFormCtx1" ) return; string $selectedTransforms[] = `ls -sl`; if ( size($selectedTransforms) == 0 ) { error( (uiRes("m_polyReFormSetTool.kNoSelection")) ); return; } string $selectedShapes[] = `listRelatives -c $selectedTransforms[0]`; if ( size($selectedShapes) == 0 ) { error( (uiRes("m_polyReFormSetTool.kNoShapeSelected")) ); return; } string $selectedShape = $selectedShapes[0]; string $reformNodes[] = `listConnections -d false ($selectedShape+".inMesh")`; if ( size($reformNodes) == 0 || `nodeType $reformNodes[0]` != "polyReForm" ) { error( (uiRes("m_polyReFormSetTool.kNoReFormNode")) ); return; } string $reformNode = $reformNodes[0]; string $reformSourceAttrs[] = `listConnections -d false -p true $reformNode.inMesh`; string $reformOrigin = `createNode "mesh" -name "reFormOrigin" -parent $selectedTransforms[0]`; assignSG initialShadingGroup $reformOrigin; connectAttr $reformSourceAttrs[0] ($reformOrigin+".inMesh"); select $selectedTransforms; string $tool = "polyReFormCtx1"; if( ! `polyReFormCtx -exists $tool` ) polyReFormCtx; setToolTo $tool; scriptJob -runOnce true -event "ToolChanged" "delete reFormOrigin"; }