• Mason Smigel

Container gotchas

Updated: Mar 23

Containers act as a way to add relationships between a container and node without a DAG hierarchy or DG connection. Maya also sometimes refers to them as 'assets' however the API uses the name container so that's the convention I adopted as well.


Working with containers has proved to be an incredibly powerful workflow for managing data, however, there are some gotchas I ran into when using components. In this post I'll list some of the issues I ran into and the solutions I found to counteract them.


Nodes hidden in outliner

One of the first things I noticed when using containers is that containers sometimes show under the container not the parent node, or hide them completely.


In this file, the sphere is parented under the 'sphere_hrc' however it does not appear under that or the container. This is because the display for asset contents is set to 'None'.



The solution to this is super simple, under the Outliner > Display > Advanced Asset Contents you can change how assets display in the outliner.


However, this is one of the many things that can be a pain to adjust every time Maya imports or references a file with containers.






Published attrs in the channel box

When containers have published attributes they appear at the top of the channel box for all contained nodes.


Once again this behavior is not necessarily bad, however most, animators I asked about this did not appreciate their current controls attributes appearing lower in the channel box.


Again this can be easily removed by unchecking the button: Show>Assets> Show at Top


nodes don't appear in node editor

Finally, (and in my opinion most annoyingly) nodes within a container do not appear in the node editor by default.


I don't know exactly where in the UI you can disable this, I found a flag in the documentation to fix this. This makes the node editor behave like you would normally expect.

cmds.nodeEditor('nodeEditorPanel1NodeEditorEd', e=True, useAssets=False)


Solution

While these issues are not too much to change on their own, and can easily be fixed manually or with a couple lines of code in a userSetup.py file, that then becomes another step everyone working with the rigs needs to accomplish in order to start working.

Instead, I ended up using a script node to fix these gotchas when the file is opened/imported/ or referenced. The script node gets created during the publishing step of the file.


def sainityCheck():
    """
    Run several checks to make sure maya is setup to work with containers.
    There are a couple 'gotcha's' to look out for
    """

    # set 'use assets' OFF in the node editor
    cmds.nodeEditor('nodeEditorPanel1NodeEditorEd', e=True, useAssets=False)
    
    # set 'show at top' OFF in the channel box editor
    cmds.channelBox('mainChannelBox', e=True, containerAtTop=False)
    
    # set asset display is to 'under parent' 
    outliners = cmds.getPanel(typ='outlinerPanel')
    for outlinerPanel in outliners:
        cmds.outlinerEditor(outlinerPanel, e=True, showContainerContents=0)
        cmds.outlinerEditor(outlinerPanel, e=True, showContainedOnly=0)

Code used within the script node