PDA

View Full Version : Problem with Class on Python


noobmode
12-09-2012, 10:21 AM
Hi
I have some trouble with assign function which have argument to Maya's checkbox.

pm.checkBox('Trans',onc = self.setLockAttr(lockAttr = {'translate' : 1}),ofc = self.setLockAttr(lockAttr = {'translate': 0}))

and here is my setLockAttr def. Sorry for not post the whole script in here, its quite long

def setLockAttr(self,lockAttr):
...curSelObjs = pm.selected()
...previewMode = pm.button('previewBttn',q=True,bgc=True)
...if previewMode == [0.60799572747386887, 0.0, 0.15700007629510948]:
......for obj in curSelObjs:
.........try:
............objList[obj].editLockAttr(lockAttr)
.........except KeyError:
............pass

I think here is the problem

onc = self.setLockAttr(lockAttr = {'translate' : 1}),ofc = self.setLockAttr(lockAttr = {'translate': 0})

the self.setLockAttr() get excute right after the script running, there are some part of UI hadn't create yet, so it gave me an error. If i replace it with a function without () mark, everything going well <like self.test for example>.How should i fix this?

Thanks

CGTalk Moderation
12-09-2012, 10:21 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.