0

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?

Viktor Petrov
  • 444
  • 4
  • 13

1 Answers1

0

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.

Viktor Petrov
  • 444
  • 4
  • 13
  • 1
    https://stackoverflow.com/a/57450777/2742418, if you want the attribute for a simple setAttr, you can find it here too – DrWeeny Aug 11 '19 at 14:43
  • @DrWeeny yeah, I saw that, thanks! Though setAttr works, it does not update the outliner without explicitly refreshing it, while the MEL command does it all in one line. – Viktor Petrov Aug 12 '19 at 15:25
  • yeah it was more for knowledge, i just ripped the setAttr from doHideInOutliner. – DrWeeny Aug 12 '19 at 18:43