我想知道是否有办法获取pymel.core.getAttr()
(或maya.cmds.getAttr()
cmds用户)可以获得的属性列表。 __dict__
没有提供该列表。
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'}
所以我想知道python在执行pmc.getAttr(myCubeTrans.translate)
(或myCubeTrans.translate.get()
或myCubeTrans.getTranslation()
)
答案 0 :(得分:4)
您可能正在寻找cmds.listAttr()
可在此处获取文档:Autodesk Maya 2014 Python commands
<强>用法:强>
import maya.cmds as cmds
cmds.polyCube( n="myCube")
print cmds.listAttr( "myCube" )
我建议你查看可用的标志来过滤一些属性(read
标志符合你的需要,因为它只会返回可读的属性)。
注意:强> 我没有检查pyMel版本,但我想这是实现的并且工作方式相同。
更新1:快速&amp;查看所有属性及其类型的脏方法
for attr in cmds.listAttr( "myCube", r=True ):
try:
print attr, " ", cmds.getAttr("myCube."+attr)
except:
print "Error reading data"
<强> UPDATE2:强> PyMel中也提供PyMel doc: listAttr。