The "dagContainer" asset node in Maya has a "blackBox" attribute, which when enabled hides the contents of the asset node's hierarchy in the outliner.
A transform node also has the same attribute, however it is hidden and when enabled it does not hide the contents of the node hierarchy in the outliner, for example:
from maya import cmds
cmds.createNode('transform', name='test')
cmds.createNode('transform', name='child')
cmds.parent('child', 'test') # creating some hierarchy;
print cmds.getAttr('test.blackBox') # returns False;
cmds.setAttr('test.blackBox', True) # no effect;
Similarly to an asset DAG container node, is it possible to enable the same "black box" functionality with a transform node? Or is there any other way to programatically hide a transform node's hierarchy in the Maya outliner?
For anyone with a similar issue, my solution was to use the "doHideInOutliner" MEL command:
from maya import cmds, mel
def node_hierarchy_display(root_node, show=True):
for node in cmds.listRelatives(root_node,
children=True,
fullPath=True):
cmds.select(node)
mel.eval('doHideInOutliner {};'.format(int(not show)))
cmds.select(clear=True)
This achieves the same result is the "blackBox" attribute of a container node.