You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Maya(含2018)如何用Python切换‘ignore hidden in outliner’标志?

How to Toggle Maya's "Ignore Hidden in Outliner" via Python (Maya 2018 Included)

Got it, let's break this down—this is a common gotcha when scripting Maya's outliner, especially since the property names aren't always intuitive. I’ve run into this exact issue before, so here’s how to fix it:

The Core Problem

You’re trying to control the outliner’s "Ignore Hidden in Outliner" toggle, which overrides the hiddenInOutliner property on individual nodes (like your hid node). The confusion usually comes from mixing up panel-level settings with node-level settings, or using the wrong command/property name.

Step 1: Target the Correct Outliner Panel

First, you need to make sure you’re referencing the right outliner panel. If you’re working with the active outliner, you can grab it dynamically; if you know the panel name (like outlinerPanel1), you can hardcode it:

import maya.cmds as cmds

# Get the currently focused outliner panel (falls back to default if none is focused)
active_outliner = cmds.getPanel(withFocus=True)
if not active_outliner.startswith("outliner"):
    active_outliner = "outlinerPanel1"  # Default outliner panel name

Step 2: Toggle the "Ignore Hidden" Setting

The outliner’s "Ignore Hidden in Outliner" option maps directly to the showHidden property in the outlinerEdit command. Here’s how to toggle it, or set it explicitly:

Toggle the setting on/off

# Check current state of the "Ignore Hidden" option
current_state = cmds.outlinerEdit(active_outliner, query=True, showHidden=True)

# Flip the state
cmds.outlinerEdit(active_outliner, edit=True, showHidden=not current_state)

Force enable/disable the setting

# Enable "Ignore Hidden in Outliner" (shows nodes marked as hidden)
cmds.outlinerEdit(active_outliner, edit=True, showHidden=True)

# Disable "Ignore Hidden in Outliner" (hides nodes marked as hidden)
cmds.outlinerEdit(active_outliner, edit=True, showHidden=False)

Why You Might Have Been Stuck

  • Wrong command: Using outlinerPanel instead of outlinerEdit—the former is for creating/managing panels, while the latter edits their display settings.
  • Misnamed property: The toggle isn’t called something obvious like ignoreHidden—it’s showHidden, where True means "show hidden nodes" (i.e., ignore their hiddenInOutliner flag), and False means "respect the node’s hidden flag".

Testing with Your Example

For your hid node:

  • If cmds.getAttr("hid.hiddenInOutliner") returns True, but the outliner has showHidden=True, the node will stay visible.
  • Running cmds.outlinerEdit(active_outliner, edit=True, showHidden=False) will immediately hide the hid node, since the outliner now respects its hidden flag.

内容的提问来源于stack exchange,提问作者winteralfs

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 06:37:35