2
我想知道是否有辦法獲得我們可以通過pymel.core.getAttr()
(或maya.cmds.getAttr()
爲cmds用戶)獲得的屬性列表。 __dict__
不會提供該列表。PYTHON在MAYA:獲取所有屬性
import pymel.core as pmc
myCubeTrans, myCubeShape = pmc.polyCube()
>>> print myCubeTrans.__dict__
{'__apiobjects__': {'MDagPath': <maya.OpenMaya.MDagPath; proxy of <Swig Object of type 'MDagPath *' at 0x00000000132ECCC0> >, 'MObjectHandle': <maya.OpenMaya.MObjectHandle; proxy of <Swig Object of type 'MObjectHandle *' at 0x00000000132EC9F0> >, 'MFn': <maya.OpenMaya.MFnTransform; proxy of <Swig Object of type 'MFnTransform *' at 0x00000000132ECA80> >}, '_name': u'pCube1'}
>>> print myCubeShape.__dict__
{'__apiobjects__': {'MObjectHandle': <maya.OpenMaya.MObjectHandle; proxy of <Swig Object of type 'MObjectHandle *' at 0x000000001326DD50> >, 'MFn': <maya.OpenMaya.MFnDependencyNode; proxy of <Swig Object of type 'MFnDependencyNode *' at 0x00000000132ECD50> >}, '_name': u'polyCube1'}
所以我想知道蟒蛇正在尋找時,它執行pmc.getAttr(myCubeTrans.translate)
(或myCubeTrans.translate.get()
或myCubeTrans.getTranslation()
)
感謝@DrHaze,listAttr()與pymel完美合作。這正是我需要的。但我無論如何都好奇地想知道這個屬性列表存儲在哪裏,所以如果有人知道它,我很感興趣:)(如果有類似'__dict__'的方法) – Morgan
python對象與什麼類似你從maya.cmds回來 - 這實際上只是一個字符串,你需要調用命令來獲取附加到對象的屬性列表。因爲它們可以動態添加,所以它們不是類定義的一部分。 Pymel把手柄放在底層的瑪雅物體上,但同樣的警告基本上是正確的。 'listAttr'是要走的路。 – theodox