Compound attrs don't seem to be real attrs at all. More like a grouping system for attributes. So really all attributes are created at the root level. See below...
-Dave import pymel.core as pCore Cube = pCore.PyNode("pCube1") # Compund Attrs are effectively null containers and NOT attributes per say. Cube.addAttr('CompoundLevel1', nc=1, at='compound') Cube.addAttr('CompoundLevel2', nc=1, at='compound') Cube.addAttr('CompoundLevel3', nc=1, at='compound') # Hence this returns False print Cube.hasAttr("CompoundLevel1") print Cube.hasAttr("CompoundLevel2") print Cube.hasAttr("CompoundLevel3") # Now add some real attributes Cube.addAttr("MessageA", at='message', parent='CompoundLevel1') # Now query if the Compound exists... print Cube.hasAttr("CompoundLevel1") # >> True # But all attributes are really at the root level and compound # attrs are a fictional grouping mechanism print Cube.MessageA.outputs() # >> [] # You can also access from the longName print Cube.CompoundLevel1.MessageA.outputs() # >> [] # Lets see if there is an Error if we try to put a attr onto # the Cube with the same name but in a different compound level Cube.addAttr("MessageA", at='message', parent='CompoundLevel2') # Warning: Name 'MessageA' of new attribute clashes with an existing attribute of node 'pCube1'. # # Error: Found no valid items to add the attribute to. # Traceback (most recent call last): # File "<maya console>", line 1, in <module> # File "C:/ArtPipelines/App/Maya2011-x64/pymel/pymel\pymel\core\nodetypes.py", line 436, in addAttr # return general.addAttr( unicode(self), **kwargs ) # File "C:/ArtPipelines/App/Maya2011-x64/pymel/pymel\pymel\core\general.py", line 619, in addAttr # res = cmds.addAttr( *args, **kwargs ) # File "C:/ArtPipelines/App/Maya2011-x64/pymel/pymel\pymel\internal\pmcmds.py", line 98, in wrappedCmd # res = new_cmd(*new_args, **new_kwargs) # RuntimeError: Found no valid items to add the attribute to. # On Thu, May 27, 2010 at 12:33 AM, shawnpatapoff <shawnpatap...@gmail.com> wrote: > Just to add to the discussing. I'm have some odd issues with nesting > attributes as in they don't seem to get created reliable. > > c1 = polyCube()[0] > c1.addAttr('Anim', nc=1, at='compound') > print c1.hasAttr('Anim') > #result False > c1.addAttr('Attr_A', nc=1 ,at='compound',parent='Anim') > print c1.hasAttr('Anim') > #result False > c1.addAttr('Attr_B', nc=1, at='compound', parent = 'Attr_A') > print c1.hasAttr('Anim') > #result False > c1.addAttr('Attr_C', at='message', parent='Attr_B') > print c1.hasAttr('Anim') > #result True > > So the the entire structure doesn't exist until 'Attr_C' is added. Is > there something wrong in my logic? > > Cheers, > Shawn > > On May 25, 12:02 pm, shawnpatapoff <shawnpatap...@gmail.com> wrote: >> Hey David, >> >> Looks like compound is the way to go, a bit of a pain to manage but it >> does what I was looking for. And you can use '.message' >> >> Cheers, >> Shawn >> >> On May 25, 11:00 am, David Moulder <da...@thirstydevil.co.uk> wrote: >> >> > I think your after a compound attribute. I'm not sure if a message >> > link can be a compound attribute tho. >> >> > FYI >> >> >http://www.rtrowbridge.com/blog/2009/03/python-api-compound-attribute/ >> >> > -Dave >> >> > On Tue, May 25, 2010 at 5:37 PM, shawnpatapoff <shawnpatap...@gmail.com> >> > wrote: >> > > Anyone know how to make sub attributes at all, or is it possible? >> >> > > What I'm trying to do is. >> >> > > object.myAttr.subAttr >> >> > > I'm using .message for my connections, not sure if it's even possible. >> >> > > Cheers, >> > > Shawn >> >> > > -- >> > >http://groups.google.com/group/python_inside_maya >> >> > -- >> > David Moulderhttp://www.google.com/profiles/squish3d >> >> > --http://groups.google.com/group/python_inside_maya >> >> > > -- > http://groups.google.com/group/python_inside_maya > -- David Moulder http://www.google.com/profiles/squish3d -- http://groups.google.com/group/python_inside_maya