Monday 25 October 2010

RE: mel. Place loc on Joint

Update to previous post now ive had chance to test script, so couple of minor changes.


//script to place a locator at position of every joint in scene (if nothings selected) or at the position of every joint in heirachy underneath selection and rename to match joint.
string $mySel[]=`ls -sl` ; string $joints[]=`ls -type joint` ; if(size($mySel)==0) for($i=0;$i<(size($joints));$i++) { float $jntPos[] = `xform -q -ws -piv ($joints[$i])` ; string $loc[] = `spaceLocator -p $jntPos[0] $jntPos[1] $jntPos[2] -n (($joints[$i])+"_loc")` ; for($b =0; $b<(size($loc)); $b++) { select ($loc[$b]) ; CenterPivot ; } } } if(size($mySel)>=1) { select -hi ; string $selJoints[] = `ls -sl` ; for($a=0;$a<(size($selJoints));$a++) { float $selJntPos[] = `xform -q -ws -piv ($selJoints[$a])` ; string $loc[] = `spaceLocator -p $selJntPos[0] $selJntPos[1] $selJntPos[2] -n (($selJoints[$a])+"_loc")` ; for ($b =0;$b<(size($loc));$b++) { select ($loc[$b]) ; CenterPivot ; } } }

Sunday 24 October 2010

mel. Place loc on joint

just thinking bout speeding up my productivity led me to just write this little script to place and rename a locator at the position of every joint in the scene (if nothing is selected) or just on the current heirachy of the selection. (i havent even tested this as im on the laptop with no maya :( ) all just from top of me head :)

its not a global proc as its meant to be assigned to a shelf button, but may include into rigging toolset currently WIP (as is an animation toolset and modelling toolset - latter already has a beta version i use at work often already, so the v01 release wont be too long and will be found on here, my website - once finished - and creativeCrash.com)
//script to place a locator at position of every joint in scene (if nothings selected) or at the position of every joint in heirachy underneath selection and rename to match joint. string $mySel[] = `ls -sl' ; string $joints[] = `ls -type joint` ; if (size($mySel) == 0) { for ($i =0; $i<(size($joints)); $i++) { string $jointPos[] = `xform -q -ws -piv ($joints[$i])` ; string $loc = `spaceLocator -p $jointPos[0] jointPos[1] jointPos[2] (($joints[$i])+"_loc")` ; //rename (($joints[$i])+"_loc") $loc ; } } if (size($mySel) >= 1) { select -hi ; string $selJoints[] = `ls -sl` ; for ($a =0; $a<(size($selJoints)); $a++) { string $selJointPos[] = `xform -q -ws -piv ($selJoints[$a])` ; string $loc = `spaceLocator -p $selJointPos[0] selJointPos[1] selJointPos[2] (($selJoints[$a])+"_loc")` ; //rename (($selJoints[$a])+"_loc") $loc ; } }

Update

so, besides some heavy rigging and rigging tests (including some awesome FK tails made from IK splines switching to scalable and controllable auto-tails), ive started to learn python (to later move on to pymel) and i still cant click with it yet... nether the less, i've also still been helping few people out with mel.

managed to pull off my first scriptJob too, after few minutes reading up on it and bout 20 mins playing with tests. its fairly simple and really powerful, just dont want to get too caught up in using them too much.

it was as simple as creating a global proc to update two opposite curves with position and apply to the others limit (to use them as a min and max) then with one scriptJob line to run on a new selection, it worked perfectly, including setting it into the startup expressions with the relevant file (the only problem was cancelling the bugger when its not needed automatically as the "if (objExists ("object") ==1)" loop didnt seem to work :( still though its something i think i'll implement to the rigs with scripts to run on selecting certain controllers etc.

its all good fun...