Created
December 30, 2015 16:01
-
-
Save berniebernie/560f715f65da2c5d3848 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //all procedures require writeToTextFileAndOpen() proc @ https://gist.github.com/berniebernie/c493e1d13a8aa5a4f161 | |
| // | |
| // 1) output translate, rotate, scale for the current frame to a text file | |
| // | |
| $file = ""; | |
| $file += "\n\n//==========EDIT AND PASTE IN THE SCRIPT EDITOR ===========================================================\n\n\n"; | |
| for($o in `ls -sl -l`){ | |
| float $po[] = `getAttr ($o+".translate")`; | |
| $file += ("setAttr (\""+$o+".translate\") "+$po[0]+" "+$po[1]+" "+$po[2]+";\n"); | |
| float $ro[] = `getAttr ($o+".rotate")`; | |
| $file += ("setAttr (\""+$o+".rotate\") "+$ro[0]+" "+$ro[1]+" "+$ro[2]+";\n"); | |
| float $sc[] = `getAttr ($o+".scale")`; | |
| $file += ("setAttr (\""+$o+".scale\") "+$sc[0]+" "+$sc[1]+" "+$sc[2]+";\n"); | |
| } | |
| writeToTextFileAndOpen($file,"",1) | |
| // | |
| // 2) output shader assignements to text file (no per-face assignement though) | |
| // | |
| $file = ""; | |
| $file += "\n\n//==========EDIT AND PASTE IN THE SCRIPT EDITOR ===========================================================\n\n\n"; | |
| for($o in `ls -sl -l`){ | |
| string $shapes[] = `listRelatives -s -f $o`; | |
| if(`nodeType $shapes[0]` == "mesh"){ | |
| for($p in `listConnections $shapes[0]`){ | |
| $type = `nodeType $p`; | |
| if($type == "shadingEngine"){ | |
| $u = ""; | |
| for($i = 1;$i<=40 - size($p);$i++){ | |
| $u += " "; | |
| } | |
| $file += ("\nsets -forceElement "+$p+""+$u+""+$o+";"); | |
| break; //stops at first shader found | |
| } | |
| } | |
| } | |
| } | |
| writeToTextFileAndOpen($file,"",1) | |
| // | |
| // 3) selection to text file | |
| // | |
| string $sel[] = `ls -sl -l`; | |
| string $file = "select -add "+stringArrayToString($sel," "); | |
| writeToTextFileAndOpen($file,"",1); | |
| // | |
| // 4) skinning to text file -- / ! \ this can take time but it should't hang maya forever | |
| // | |
| string $file = ""; | |
| $file += "\n\n//==========EDIT AND PASTE IN THE SCRIPT EDITOR ===========================================================\n\n\n"; | |
| string $vertices[] = `ls -sl -fl -l`; | |
| string $selObj[] = `ls -o -sl`; | |
| if(size($vertices)>0){ | |
| string $sck = `findRelatedSkinCluster($selObj[0])`; | |
| for($vertex in $vertices){ | |
| string $skinInfluences[]=`skinPercent -ib 0.000001 -q -t $sck $vertex`; | |
| float $sknVals[] = `skinPercent -ib 0.000001 -q -v $sck $vertex`; | |
| $file += "skinPercent -zri 1"; | |
| for($i=0;$i<size($skinInfluences);$i++){ | |
| if($sknVals[$i] > 0){ | |
| $file += " -tv "+$skinInfluences[$i]+" "+$sknVals[$i]; | |
| } | |
| } | |
| $file += " "+$sck+" "+$vertex+";\r\n"; | |
| } | |
| writeToTextFileAndOpen($file,"",1); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment