0

Using Maya 2018, how can I write a simple Python command that will toggle the outliner flag, 'ignore hidden in outliner' ? I am having trouble accessing that panel attribute using the outlinerPanel command and the outlinerEdit commands.

enter image description here

Here is an example of the node, 'hid', having its attribute, 'Hidden in Outliner' checked on, but it is still visible in the outliner because the outliner option, 'ignore hiddenInOuliner' has been toggled on.

enter image description here

winteralfs
  • 459
  • 6
  • 25

2 Answers2

1
def setHiddenInOutliner(nodes=list, value=bool):
    for n in nodes:
        cmds.setAttr('{}.hiddenInOutliner'.format(n), value)

    # refresh any outliner editors
    eds = cmds.lsUI(editors=True)
    for ed in eds:
        if cmds.outlinerEditor(ed, exists=True):
            cmds.outlinerEditor(ed, e=True, refresh=True)

Here is the code im using, it is just a simple attribute

DrWeeny
  • 2,487
  • 1
  • 14
  • 17
  • Thanks, while this does toggle the attribute on the node level, I was looking for a way to toggle the UI outliner option to 'ignore hiddenInOutliner.' I did not want to change that attribute on the nodes themselves. – winteralfs Aug 13 '19 at 12:51
  • The toggle in the outliner UI is triggering the attribute. There is a way to refresh the outliner so it will be correctly updated after the setAttr – DrWeeny Aug 13 '19 at 12:54
  • This tick box is triggering the proc : doHideInOutliner, you can do whatIs on it to find the command to refresh the outliner or you can wrap the mel proc – DrWeeny Aug 13 '19 at 12:56
  • I do not believe that to be correct. So when toggling the option to ignore hidden in outliner, your saying ever node in the Maya scene will have that attribute disabled? And when you toggle that option off in the outliner, the attributes on the nodes return to the state they were in before the option in the outliner was toggled? – winteralfs Aug 13 '19 at 12:56
  • Yes, that what the toggle do. It parse all the dag hierarchy and refresh the outliner display. It is triggering the mel proc "doHideInOutliner" that you can find with whatIs command – DrWeeny Aug 13 '19 at 12:59
  • I will post a picture on my original question to demonstrate what I mean. Thanks for your help with this. – winteralfs Aug 13 '19 at 13:02
  • I've edited with the refresh part. if you echo all command, you will see the script that is triggered by ticking this box – DrWeeny Aug 13 '19 at 14:21
1

This is part of the Maya outlinerEditor command and be done using:

from maya import cmds

outliner = "outlinerPanel1"
cmds.outlinerEditor(outliner, edit=True, ignoreHiddenAttribute=False)
cmds.outlinerEditor(outliner , edit=True, refresh=True)

You'll need to make sure you have the right outliner name for the one you want to act upon. I believe the default outliner is outlinerPanel1 in about 99% of the time - but with maya you never know.

You can also do it over all outliners:

from maya import cmds

for panel in cmds.getPanel(typ="outlinerPanel"):
    cmds.outlinerEditor(panel, edit=True, ignoreHiddenAttribute=True)
    cmds.outlinerEditor(panel, edit=True, refresh=True)
Roy Nieterau
  • 1,226
  • 2
  • 15
  • 26