I’ve been working on an IK/FK joint matching script, that I managed to finally get working correctly last month. Today start I up Maya, run the script and while the interface loads up, I receive the following errors…
This one upon running loading script:
# Error: NameError: file <maya console> line 196: global name 'Fks' is not defined #
and this one upon clicking my ‘select root joint chain’ button:
# Error: NameError: file <maya console> line 1: name 'select_joints_afk' is not defined #
I’m really new to this so I really don’t understand what exactly is going on
class Create_Selection_Chains(object):
def __init__(self, name, *args):
self.Fks = Fks
self.Ikw = Ikw
self.Pv = ikpv
self.name = name
self.combined_selection = self.Fks+self.Ikw+self.Pv
print("List created"+self.name)
def select_joints_afk(self):
if cmds.ls(selection = True,type=("transform",'nurbsCurve')):
sel = cmds.ls(sl=True)
fks = sel
fkCtrls = cmds.listRelatives(sel, allDescendents=True, type=("transform",'nurbsCurve'))
Fks = [nurbsCurve for nurbsCurve in fkCtrls if nurbsCurve.startswith('FK') & nurbsCurve.endswith('Ctrl')]
cmds.textFieldButtonGrp(gtF0, edit = True, tx ='' .join(sel),buttonLabel='IK OK',backgroundColor = (.5,.8,.2))
del Fks[1]
del Fks[2]
Fks.extend(sel)
print Fks
return self.Fks
else:
text = cmds.confirmDialog( title='Error', message='Must select joint', button=['OK'],
defaultButton='Ok', dismissString='No' )
def select_joints_aikw(self):
if cmds.ls(selection = True,type=("transform",'nurbsCurve')):
sel=cmds.ls(selection = True)
ikwrist = sel
Ikw = [nurbsCurve for nurbsCurve in ikwrist if nurbsCurve.startswith('IK') & nurbsCurve.endswith('Ctrl')]
cmds.textFieldButtonGrp(gtF1, edit = True, tx ='' .join(ikwrist),buttonLabel='IK OK',backgroundColor = (.5,.8,.2))
cmds.select(ikwrist)
print Ikw
return self.ikw
else:
text = cmds.confirmDialog( title='Error', message='Must select joint', button=['OK'], defaultButton='Ok',
dismissString='No' )
def select_joints_ikpv(self):
if cmds.ls(selection = True,type=("transform",'nurbsCurve')):
sel = cmds.ls(sl=True)
ikPvsel = sel
ikpv = [nurbsCurve for nurbsCurve in ikPvsel if nurbsCurve.startswith('IK') & nurbsCurve.endswith('Ctrl')]
cmds.textFieldButtonGrp(gtF2, edit = True, tx ='' .join(ikPvsel),buttonLabel='IK OK',backgroundColor = (.5,.8,.2))
cmds.select(ikPvsel)
print ikpv
return self.ikpv
else:
text = cmds.confirmDialog( title='Error', message='Must select joint', button=['OK'],
defaultButton='Ok', dismissString='No' )
Looking at another thread here, it seems that the error might have occurred because I closed Maya?
If you need to see the code in its entirety, I can send a link if it helps…