// =========================================================================== // 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: Oct 31 2014 // // Description: // This script provides a way to set the target for sculpting/tweaks on a blendshape node. // // global proc setSculptTargetIndex( string $blendShape, int $idx, int $ivm, float $ibWeight ) { string $attr = $blendShape; $attr += ".inputTarget"; int $nbInputs = `getAttr -size $attr`; int $indices[] = `getAttr -multiIndices $attr`; if($nbInputs == 0) return; for( $i = 0; $i < $nbInputs; $i++ ) { int $index = $indices[$i]; $attr = $blendShape + ".inputTarget[" + $index + "].sculptTargetIndex"; int $oldIdx = `getAttr $attr`; string $attrIbWeight = $blendShape + ".inputTarget[" + $index + "].sculptInbetweenWeight"; float $oldIbWeight = `getAttr $attrIbWeight`; //If nothing need to be done if($oldIdx == -1 && $idx == -1) return; if( $oldIdx == $idx && abs($oldIbWeight-$ibWeight) < 1e-5 ) $idx = -1; setAttr $attrIbWeight $ibWeight; setAttr $attr $idx; } if( $ivm == 1 ) { if( $idx > -1 ) { string $msg; string $editTargetName; if(abs($ibWeight-1.0) < 1e-5) { $editTargetName = $blendShape + ".weight[" + $idx + "]"; $editTargetName = `aliasAttr -q $editTargetName`; $msg = (uiRes("m_setSculptTargetIndex.kEnabledBlendSculptTarget")); } else { int $inbetweenIndex = 5000 + $ibWeight * 1000; string $ibTargetNamePlug = $blendShape + ".inbetweenInfoGroup[" + $idx + "].inbetweenInfo[" + $inbetweenIndex + "].inbetweenTargetName"; $editTargetName = `getAttr $ibTargetNamePlug`; $msg = (uiRes("m_setSculptTargetIndex.kEnabledBlendSculptIBTarget")); } $msg += $editTargetName; inViewMessage -smg $msg -pos "botCenter" -fade; } else { inViewMessage -clear "botCenter"; string $msg = (uiRes("m_setSculptTargetIndex.kDisabledBlendSculptTarget")); $msg += $blendShape; inViewMessage -smg $msg -pos "botCenter" -fade; } } }