//===================================================================== // SCRIPT: drago_bsExtractSelected // AUTHOR: Drago Avdalovic // DATE: Dec 10, 2006 // PROCEDURE: drago_bsExtractSelected (global) // ARGUEMENTS: no arguments // DESCRIPTION: spits selected target shapes // // USAGE: select bs geo, select blendShape node in channel box, select name of the of the target-s and run the script // RETURN: string array with spited targets //====================================================================== //------------ update:Mar. 28/2007---added turning off and on deformers and polyAverage nodes global proc string[] drago_bsExtractSelected() { $objList = `channelBox -q -hol mainChannelBox`; string $obj[] = `ls -sl -type transform`; string $bs[] = `ls -type blendShape $objList`; string $BS=$bs[0]; //--------- main blendShape string $conns[]; //--------- names of drivers conections string $dup[]; string $namesBS[]=`drago_namesBS $BS`; int $indexBS[]=`drago_indexBS $BS`; string $tarSel[] = `channelBox -q -selectedHistoryAttributes mainChannelBox`; string $lockedAttr[]; //-----names of the locked attr float $valLocked[]; // ------value of the locked attr setAttr ($BS + ".envelope") 1; int $j=0; for ($s=0; `size($tarSel)` >= $s; $s++) { if (`objExists($tarSel[$s])`!=0) error ("Object with the name - "+$tarSel[$s]+" - exists in the scene already!"); } string $hist[]=`listHistory $obj[0]`; string $skinCluster[]=`ls -type skinCluster $hist`; //-- turn off polyAverageVertex nodes if exists/disconnect them if connected string $pav[]=`ls -type polyAverageVertex $hist`; int $pavValues[]; string $pavConnections[]; for ($k=0; $k "+$pav[$k]+".iterations ...\n"); } else { $pavValues[$k]=`getAttr ($pav[$k]+".iterations")`; $pavConnections[$k]=""; setAttr ($pav[$k]+".iterations") 0; } } } //-- check for future deformers and turn their envelope to 0 string $futureDeformers[]=bs_deformersPastFutureByName ($obj[0], $BS,1); if (size($futureDeformers)>0) { for ($deformer in $futureDeformers) { if (`objExists $deformer`) { setAttr ($deformer + ".envelope") 0; print ("\nSetting envelope : "+$deformer+" .envelope to 0 ...\n"); } } } //----------- disconnect shapes from driver and unlock locked attr int $f=0; for ($each in $namesBS) { if (`getAttr -lock ($BS + "." + $each)`) { $valLocked[$f]=`getAttr ($BS + "." + $each)`; setAttr -lock false ($BS + "." + $each); $lockedAttr[$f]=($BS + "." + $each ); $f++; } string $connsTemp[] = `listConnections -scn 1 -s 1 -d 0 -p 1 ($BS + "." + $each)`; $conns[$j] = $connsTemp[0]; if (`objExists $conns[$j]`) { disconnectAttr ($conns[$j]) ($BS + "." + $each); } setAttr ($BS + "." + $each) 0; $j++; } //------------ duplicate selected shapes only for ($name in $tarSel) { for($i=0; $i "+$pav[$i]+".iterations\n"); } else { setAttr ($pav[$i]+".iterations") $pavValues[$i]; } } } if (size($futureDeformers)>0) { for ($deformer in $futureDeformers) { if (`objExists $deformer`) { setAttr ($deformer + ".envelope") 1; print ("\nSetting envelope : "+$deformer+" .envelope to 1 ...\n"); } } } return $dup; } // extracts name of the target shape //-------- argument: blend shape name //-------- retutns string array of the target index global proc string[] drago_namesBS(string $BS) { string $namesBS[]; int $j=0; string $al[]=`aliasAttr -q $BS`; for ($i=0; $i "tweak", "skinCluster", "blendShape", "ffd", "cluster", "cMuscleSystem", etc... // returns names of requested deformers in the same order as array $defType global proc string[] bs_deformersReturnDeformersNames(string $node, string $defType[]) { string $defTypeNames[]; string $allDeformers[]=ls("-type", "geometryFilter",`listHistory -bf -il 1 -gl 1 -pdo 1 $node`); for($i=0; $i "+$allDeformers[$j]+" ..."); } else { $futureDeformers[size($futureDeformers)] = $allDeformers[$j]; } } return $futureDeformers; } global proc string[] bs_reverseStringArray(string $passed[]) { int $size = `size($passed)`; string $return[] = {""}; int $j = ($size-1); for($i=0 ; $i<$size ; $i++) { $return[$j--] = $passed[$i]; } return $return; }