Hey everyone, first post so I’m sorry if this isn’t perfectly executed, but I’m working on a Python tool for Maya that will take a rig that has multiple hierarchies and create an export skeleton that is one hierarchy that’s parented to the result/driving joints of the skeleton.
I’m not new to rigging, but pretty new to writing Python script, so I’m still having trouble thinking like a programmer. So right now, I’m really just looking to make a plan of attack and just wrap my head around what needs to happen. I’ve gone through the process dozens of times and I know the order of operations to make an export skeleton and i’ve gotten to the point where I can select the root joint and create a new joint chain over it, but as far as how to list all the new joints in the right order and then parent them to the result joint, i’ve hit a wall.
My other issue is getting it to create the hierarchies in the same manner as the rig, if that makes little sense, here are pictures…(sorry they got tiny, i don’t know how to fix that yet)
here’s how one branch looks in my rig so you can see what i’m talking about, they all kind of look like this, this one more simple than the rest though. My goal is to take all the “result” joints and make an export skeleton that’s in the same positions as and parented to them that you can use to export to other programs/engines that don’t support rigs with multiple hierarchies.
right now, if i select neck_base_result_JNT and run the script, it’ll work because the chain ends and you’ll just get a copy of the result joints, however if you select Root_Transform_CTRL and hit the button that pops up when you run the script, it’ll select every joint in the rig and arrange them like this. My issue is figuring out a way to tell it to build it like it’s built in the rig.
this is what it’s supposed to look like…
Obviously, I haven’t done the constraint part yet, but i figure if i can figure out how to list all the new joints in the right order, i can figure out the parenting part.
and then for fun, here’s what I have so far, it creates a little UI button because I was bored…
import maya.cmds as cmds
def JMSexportSkeletonMakerUI():
if cmds.window("EskelMakerWindow", exists=True):
cmds.deleteUI("EskelMakerWindow", window=True)
if cmds.windowPref("EskelMakerWindow", exists=True):
cmds.windowPref("EskelMakerWindow", remove=True)
cmds.window("EskelMakerWindow", title="eskelmkr", \
sizeable=False, minimizeButton=False, maximizeButton=False, tlc=[192, 47])
cmds.columnLayout("EskelMakerWindowMainUI", parent="EskelMakerWindow")
cmds.rowColumnLayout(nc=1, cw=[(1, 200)], p="EskelMakerWindowMainUI")
cmds.button(l="mk n xprt skltn fm slctd jnts", bgc=(.9,.3,.1), command=lambda args:skeletonFromSelection())
cmds.showWindow("EskelMakerWindow")
def skeletonFromSelection():
cmds.select(hi=True)
selecetObjects=cmds.ls(ap=True, sl=True, type="joint")
cmds.select(clear=True)
if selecetObjects != []:
for each in selecetObjects:
pos = cmds.xform(each, query=True, ws=True, rp=True, )
cmds.joint(n=(each+"_exportJNT"), p=(pos[0], pos[1], pos[2]))
cmds.select(clear=True)