I’m getting an error when I hit my button to perform a snap.
unbound method Ik2FkSnap() must be called with Snapping instance as first argument (got list instance instead)
could someone help me understand how I should be calling this correctly?
class Snapping():
def Ik2Fk():
fkikChain = lAFKChain + lwristIKChain+ lelbowIKChain
print fkikChain
self.Ik2FkSnap(fkikChain)## I think this is my problem
def Ik2FkSnap():
#perform snap
Remember the little self - it belies an important mechanic. It refers to the bound instance of the class, and as your methods are not stated as being either class or static methods an error will be thrown.
The first argument of any bound method of the class is always a reference to the instance of the class. Self is the colloquial term for this as cls, is used for classmethods, and mcs for metaclasses. The beauty that is Python…
In your class just refer to the class instance and you should be good:
class MyClass(object) #new style classes please!
def __init__(self):
pass
def my_sweet_method(self):
print "man, i love this sh%t!"