Maya에서 Python으로 스크립트를 가져오고 다시로드하는 과정을 이해하고 싶습니다.Maya Python 호출 모듈 클래스 함수
# NameError: name 'MyClass' is not defined #
그것은 윈도우를 생성하지만 버튼을 누를 때 나에게 위의 오류를 제공합니다 :
나는 오류 다음 던졌습니다 다음과 같은 코드가 있습니다. 누군가 내가 여기서 누락 된 것을 도울 수 있다면 좋을 것입니다.
import maya.cmds as cmds
from functools import partial
class MyClass():
@classmethod
def createWindow(cls):
windowID = 'window'
if cmds.window(windowID, exists = True):
cmds.deleteUI('window')
window = cmds.window(windowID, title="Blast", iconName='Blast', widthHeight=(400, 200))
cmds.frameLayout(label='')
cmds.button(label='Playblast' ,command= 'MyClass.createPlayblast()')
cmds.showWindow(window)
@classmethod
def createPlayblast(cls):
cmds.playblast(f= "playblast", fmt= "image")
print "hallo"
MyClass.createWindow()
나는이처럼 내 MODUL를 호출 오전 :
# call loadTest
import sys
Dir = 'S:/people/Jan-Philipp/python_scripts'
if Dir not in sys.path:
sys.path.append(Dir)
try: reload(loadTest)
except: from loadTest import MyClass
loadTest.MyClass()
건배, 모두들 좋은 하루 되세요 희망!
게시물의이 줄이이 경우에 잘못 되었습니까? cmds.button (레이블 = '재생 블래스트', 명령 = 'MyClass.createPlayblast()') 은 다음과 같습니다. cmds.button (label = 'Playblast', command = 'createPlayblast()' –
예, 맞습니다. – theodox
또한 파이썬 함수를 직접 전달하는 콜백의 문자열 참조 버전을 사용하지 마십시오. 문자열 버전은 리스너와 프로덕션 코드에서 다르게 작동하므로 많은 버그가 생성됩니다. Thanks theodox https://theodox.github.io/2014/maya_callbacks_cheat_sheet – theodox