0

I'm running into a a few errors when trying to call a function. I have a button that when pressed should print snapped.

#code for button
cmds.button(label='FK 2 IK', command = 'Fk2Ik()', width=100)
cmds.button(label='IK 2 FK',  command = Snapping.Ik2Fk(), width=100)
cmds.setParent('..')
cmds.separator(h=5, style = 'none')
cmds.separator(h=5)




#code for function
class Snapping(self):   

    def Ik2Fk(self):
        print "Snapped"


'''
the error I get is this

# Error: TypeError: file <maya console> line 119: unbound method Ik2Fk() must be called with Snapping instance as first argument (got nothing instead) #

1 Answers1

0
class Snapping(self):   
    @staticmethod
    def Ik2Fk():
        print "Snapped"

cmds.button(label='FK 2 IK', command = 'Fk2Ik()', width=100)
cmds.button(label='IK 2 FK',  command = Snapping.Ik2Fk, width=100)
cmds.setParent('..')
cmds.separator(h=5, style = 'none')
cmds.separator(h=5)
DrWeeny
  • 2,487
  • 1
  • 14
  • 17