// =========================================================================== // 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: 2005 // // // // // // createHistorySwitch(string $shape, int $wantTweakNode) // // // string : name of new historySwitch node // // // Attach a historySwitch node in the history of the specified shape. // The historySwitch is a deformer that allows you to switch between // playing back the history of the shape or playing back cached // vertex positions. // // // string $shape Name of shape to attach the switch. // int $wantTweakNode Specifies whether to put a tweak node in the history of the shape. // // // string $shapeName = "clothObjectName"; // string $switch = createHistorySwitch($shapeName, false); // // ///////////////////////////////////////////////////////////////////////// global proc string createHistorySwitch(string $shape, int $wantTweakNode) { string $isDeformable[] = `ls -type deformableShape $shape`; if (0 == size($isDeformable)) { string $rels[] = `listRelatives -path -shapes -noIntermediate $shape`; $isDeformable = `ls -type deformableShape $rels`; if (0 == size($isDeformable)) { error((uiRes("m_createHistorySwitch.kNonDeformableError"))); } } string $switch[] = `deformer -type historySwitch $shape`; string $hist[] = `listHistory -pdo 1 $shape`; if (! $wantTweakNode) { for ($histNode in $hist) { if (nodeType($histNode) == "tweak") { string $dblList[] = `listAttr -m ($histNode+".plist")`; string $fltList[] = `listAttr -m ($histNode+".vlist")`; if (size($dblList) <= 1 && size($fltList) <= 1) { // we don't delete the tweak node if it contains tweaks // delete $histNode; } break; } } } string $conns[] = `listConnections -p 1 ($switch[0]+".ip[0].ig")`; connectAttr $conns[0] ($switch[0]+".ug[0]"); setAttr ($switch[0]+".playFromCache") 1; getAttr -silent ($switch[0]+".op[0]"); setAttr ($switch[0]+".playFromCache") 0; disconnectAttr $conns[0] ($switch[0]+".ug[0]"); return $switch[0]; }