I think the safest thing to do is to use the attribute's mobject.apiType() func to get the id. It can be pretty complex though because for the non-standard types, such as string you have to do multiple lookups. For instance, a string type will return you a type id of 562, for kTypedAttribute, not exactly a string type. Then you need to create an MFnTypedAttribute so you can ask it what its actual type is. You can create a base type attribute function set, MFnAttribute, to query any attribute about any of the shared settings, such as isArray, etc.
I'll stop there because I'm not sure if this is of use to you, Paul. -Judah On Thu, Jul 1, 2010 at 12:24 PM, Paul Molodowitch <[email protected]>wrote: > Hey all - I was wondering if anyone here knew of a way to query the > 'type' (ie, similar to what getAttr('foo.bar', type=True) would > return) of an attribute, for ANY attribute. Specifically, I can't > seem to find ANY way to query the type of multi-compound attribute's > children, when the multi does not have any indices created yet. > > To see what I mean: > > import maya.cmds as cmds > > def getType(node): > print "%-50s :" % node, > try: > print cmds.getAttr(node, type=True) > except Exception: > print "<ERROR>" > > getType(u'persp.publishedNodeInfo') > getType(u'persp.publishedNodeInfo.publishedNode') > getType(u'persp.publishedNode') > getType(u'persp.publishedNodeInfo[-1].publishedNode') > > getType(u'persp.instObjGroups.objectGroups') > getType(u'persp.instObjGroups.objectGroups.objectGroupId') > getType(u'persp.objectGroupId') > > Is there another way to query the type of an attribute other than > getAttr? attributeQuery doesn't seem to have any relevant flags, and I > couldn't find any way to access this information from the API. > > Any ideas? > > - Paul > > -- > http://groups.google.com/group/python_inside_maya -- http://groups.google.com/group/python_inside_maya
