Hello all,
I am working on a tool for a tool set I am building in Maya and have ran into a small problem. I am running a few checks and decided to put them into separate functions and am losing my targeted variable and can not figure out why. Here is my code.
import maya.cmds as cmds
print("jointAdd.py Loaded")
win = "jointAdd"
selJoint = cmds.ls(sl=1)
selChild = cmds.select(selJoint, hi=1)
selChildP = cmds.ls(sl=1)
selChildFinal = selChildP[1]
def gui():
if(cmds.window(win, q=1, ex=1)):
cmds.deleteUI(win)
if(cmds.windowPref(win, q=1, ex=1)):
cmds.windowPref(win, r=1)
cmds.window(win, t=win, w=300, h=125)
cmds.columnLayout("baseCol")
cmds.intSliderGrp( cw3=[75, 50, 100], field=True, label='Joint Addition', minValue=0,
maxValue=15, fieldMinValue=0, fieldMaxValue=15, value=0 )
cmds.button( l="Add Joints", w=290, c="jointAdd.orientCheck()")
cmds.showWindow(win)
def orientCheck():
'''
select -d joint1 ;
insertJoint joint1;
// Result: joint3 //
joint -e -co -p -1.52704e-018 0.942082 0 joint3;
insertJoint joint3;
// Result: joint4 //
joint -e -co -p -3.51219e-018 1.51679 0 joint4;
insertJoint joint4;
// Result: joint5 //
joint -e -co -p -5.28356e-018 2.02961 0 joint5;
'''
#Check if the joints are oriented
if(cmds.getAttr(selChildFinal + ".tx") > 0) and (cmds.getAttr(selChildFinal + ".ty") > 0):
print("Joints are not oriented correctly")
elif(cmds.getAttr(selChildFinal + ".tx") > 0) and (cmds.getAttr(selChildFinal + ".tz") > 0):
print("Joints are not oriented correctly")
elif(cmds.getAttr(selChildFinal + ".ty") > 0) and (cmds.getAttr(selChildFinal + ".tz") > 0):
print("Joints are not oriented correctly")
else:
print("Joints are oriented!")
getAxis()
def getAxis():
#Figure out joint child axis
if(cmds.getAttr(selChildFinal + ".tx") > 0):
childAxis = ".tx"
elif(cmds.getAttr(selChildFinal + ".ty") > 0):
childAxis = ".ty"
elif(cmds.getAttr(selChildFinal + ".tz") > 0):
childAxis = ".tz"
else:
print("Child is too close to subdivide")
print(selChildFinal + " is oriented down the " + childAxis + " axis.")
I do not know where I am losing it but I get this error in maya:
# Traceback (most recent call last):
# File "<maya console>", line 1, in <module>
# File "C:/Users/Carey/Documents/maya/scripts\jointAdd.py", line 50, in orientCheck
# def getAxis():
# File "C:/Users/Carey/Documents/maya/scripts\jointAdd.py", line 53, in getAxis
# childAxis = ".tx"
# TypeError: Object [] is invalid #