【发布时间】:2014-11-07 03:26:46
【问题描述】:
我正在尝试从一个类中获取值并将该特定值用于另一个类。但是我不断收到此错误 - AttributeError: 'CustomNodeTranslator' object has no attribute 'start'
基本上我正在尝试获取/传输self.start 和self.end 的值以用于ChanFileExporter 类
我不确定为什么它不起作用,但是当我在代码的另一部分应用这种类似的方法时,它工作正常。
非常感谢任何建议!
class CustomNodeTranslator(OpenMayaMPx.MPxFileTranslator):
def __init__(self):
OpenMayaMPx.MPxFileTranslator.__init__(self)
def haveWriteMethod(self):
return True
def haveReadMethod(self):
return True
def filter(self):
return "*.chan"
def defaultExtension(self):
return "chan"
def writer( self, fileObject, optionString, accessMode ):
self.start = []
self.end = []
for opt in filter(None, optionString.split(';')):
optSplit = opt.split('=')
if optSplit[1] == '0':
startAnimation = cmds.findKeyframe(which='first')
endAnimation = cmds.findKeyframe(which='last')
self.start = startAnimation
self.end = endAnimation
class ChanFileExporter():
def __init__(self, transform, startAnimation, endAnimation, cameraObj):
self.fileExport = []
testClass = CustomNodeTranslator()
mayaGlobal = OpenMaya.MGlobal()
mayaGlobal.viewFrame(OpenMaya.MTime(1))
startAnimation = testClass.start
endAnimation = testClass.end
for i in range(int(startAnimation), int(endAnimation + 1)):
...
...
【问题讨论】:
标签: python class class-variables