JaredTaylor
10-28-2010, 09:05 AM
Hi,
I just started learning python. I'm starting to write my auto rigging script.
First thing it does is create locators. These locators all always are at 0,0,0 but their 'local position' stays in world space. I want to replace the locators with joints, by taking the name and position of the locator and, for example, it takes the local position XYZ of l_hip_jnt_loc which is 3,6,0, then in case it has been moved since creation, it adds the value of translate.XYZ, then it takes the name and creates a joint with the calculated position and the same name minus the _loc.
I imagine I need to store the translate XYZ, the local position of the locator, add it, and then create a joint with those co-ordinates, I could just tell it which name to use (no need to make it work it out), then delete the locator.
I am completely lost, this is so beyond me, I have only been scripting on and off for a couple of days.
How would I do this?
My script so far looks like this:
# dummy creation script
import maya.cmds as cmds
# create a variable for creating a space locator
sl = cmds.spaceLocator
cp = cmds.CenterPivot
sel = cmds.select
# create locators for spine
sl( p=(0,10,0), n='hipIK_jnt_loc' )
cp( 'hipIK_jnt_loc' )
sl( p=(0,12,0), n='spineIK_1_jnt_loc' )
cp( 'spineIK_1_jnt_loc' )
sl( p=(0,14,0), n='spineIK_2_jnt_loc' )
cp( 'spineIK_2_jnt_loc' )
sl( p=(0,16,0), n='spineIK_3_jnt_loc' )
cp( 'spineIK_3_jnt_loc' )
sl( p=(0,18,0), n='spineIK_4_jnt_loc' )
cp( 'spineIK_4_jnt_loc' )
sl( p=(0,20,0), n='chestIK_jnt_loc' )
cp( 'chestIK_jnt_loc' )
# create locators for the left leg
sl( p=(3,10,0), n='l_hip_jnt_loc' )
cp( 'l_hip_jnt_loc')
sl( p=(3,6,0), n='l_knee_jnt_loc' )
cp( 'l_knee_jnt_loc')
sl( p=(3,2,0), n='l_ankle_jnt_loc' )
cp( 'l_ankle_jnt_loc' )
sl( p=(3,0,2), n='l_foot_jnt_loc')
cp( 'l_foot_jnt_loc' )
I just started learning python. I'm starting to write my auto rigging script.
First thing it does is create locators. These locators all always are at 0,0,0 but their 'local position' stays in world space. I want to replace the locators with joints, by taking the name and position of the locator and, for example, it takes the local position XYZ of l_hip_jnt_loc which is 3,6,0, then in case it has been moved since creation, it adds the value of translate.XYZ, then it takes the name and creates a joint with the calculated position and the same name minus the _loc.
I imagine I need to store the translate XYZ, the local position of the locator, add it, and then create a joint with those co-ordinates, I could just tell it which name to use (no need to make it work it out), then delete the locator.
I am completely lost, this is so beyond me, I have only been scripting on and off for a couple of days.
How would I do this?
My script so far looks like this:
# dummy creation script
import maya.cmds as cmds
# create a variable for creating a space locator
sl = cmds.spaceLocator
cp = cmds.CenterPivot
sel = cmds.select
# create locators for spine
sl( p=(0,10,0), n='hipIK_jnt_loc' )
cp( 'hipIK_jnt_loc' )
sl( p=(0,12,0), n='spineIK_1_jnt_loc' )
cp( 'spineIK_1_jnt_loc' )
sl( p=(0,14,0), n='spineIK_2_jnt_loc' )
cp( 'spineIK_2_jnt_loc' )
sl( p=(0,16,0), n='spineIK_3_jnt_loc' )
cp( 'spineIK_3_jnt_loc' )
sl( p=(0,18,0), n='spineIK_4_jnt_loc' )
cp( 'spineIK_4_jnt_loc' )
sl( p=(0,20,0), n='chestIK_jnt_loc' )
cp( 'chestIK_jnt_loc' )
# create locators for the left leg
sl( p=(3,10,0), n='l_hip_jnt_loc' )
cp( 'l_hip_jnt_loc')
sl( p=(3,6,0), n='l_knee_jnt_loc' )
cp( 'l_knee_jnt_loc')
sl( p=(3,2,0), n='l_ankle_jnt_loc' )
cp( 'l_ankle_jnt_loc' )
sl( p=(3,0,2), n='l_foot_jnt_loc')
cp( 'l_foot_jnt_loc' )
