// =========================================================================== // 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: // doMirrorDeformerWeightsArgList // // Description: // Mirror deformer weights // // Input Arguments: // $version: The version of this option box. Used to know how to // interpret the $args array. // "1" : $name // // $args // Version 1 // [0] $args: command flags for the mirror mode and the weight association method // [1] $deformer: the deformer to act on, or "" to determine from selection // [2] $create: whether to create a new deformer // // Return Value: // None // global proc int doMirrorDeformerWeightsArgList( string $version, string $args[]) { // Handle the different versions of arguments we accept and convert them // into a set of flat command flags // string $cmdArgs = $args[0]; string $srcDeformer = $args[1]; string $dstDeformer = ""; int $create = $args[2]; string $currentSelection[] = `ls -selection`; if ($srcDeformer == "") { string $allDeformers[] = findRelatedDeformer($currentSelection[0]); string $deformers[] = `ls -type weightGeometryFilter $allDeformers`; if (size($deformers) > 1) { error((uiRes("m_doMirrorDeformerWeightsArgList.kDeformerUnspecified"))); } else if (size($deformers) == 0) { error((uiRes("m_doMirrorDeformerWeightsArgList.kNoDeformer"))); } $srcDeformer = $deformers[0]; } string $deformerType = nodeType($srcDeformer); if ($create) { int $selSize = size($currentSelection); string $destShape = ""; // Get the destination shape. if ($selSize == 1) $destShape = $currentSelection[0]; else if ($selSize == 2) $destShape = $currentSelection[1]; string $destSet[] = `listConnections -type objectSet $srcDeformer`; string $destSelection[]; string $s; for ($s in $destSet) { string $members[] = `sets -q $destSet[0]`; string $m; for ($m in $members) { if (startsWith($m, $destShape)) $destSelection[size($destSelection)] = $m; } } select -r $destSelection; // Create the appropriate deformer. string $newDeformer[]; if ($deformerType == "cluster") $newDeformer = `cluster -frontOfChain`; else if ($deformerType == "softMod") $newDeformer = `softMod -frontOfChain`; else if ($deformerType == "wire") $newDeformer = `wire -frontOfChain`; else if ($deformerType == "jiggle") { $newDeformer = `duplicate`; deformer -e -geometry $destShape $newDeformer[0]; } else if (`objectType -isa weightGeometryFilter $srcDeformer`) { string $nodeType = nodeType($srcDeformer); $newDeformer = `deformer -type $nodeType`; } else { warning((uiRes("m_doMirrorDeformerWeightsArgList.kDeformerTypeWarning"))); return 0; } $dstDeformer = $newDeformer[0]; // Restore the selection. select -r $destSelection; } // construct the command // string $cmd = ("copyDeformerWeights -sd " + $srcDeformer + " -ss " + $currentSelection[0]); if (size($currentSelection) == 2) $cmd += (" -ds " + $currentSelection[1]); else $cmd += (" -ds " + $currentSelection[0]); if ($dstDeformer != "") $cmd += (" -dd " + $dstDeformer); $cmd += $cmdArgs; evalEcho($cmd); return 1; }