Question
Can one hotkey show a Geometry Nodes pie without also showing it in Shader Editor or Compositor?
Answer
Yes. Give each menu a Poll method that returns True only for its Node Editor subtype. PME will not invoke a menu whose Poll returns False.
For a Geometry Nodes menu:
return C.area and C.area.ui_type == "GeometryNodeTree"Make separate menus for the other node editors rather than trying to put every tool into one large menu:
# Shader Editor
return C.area and C.area.ui_type == "ShaderNodeTree"
# Compositor
return C.area and C.area.ui_type == "CompositorNodeTree"
Set it up
- Create the Geometry, Shader, or Compositor menu as usual.
- Open that menu’s advanced settings and enter the matching expression in Poll.
- Return a boolean.
returnis required; writing only the comparison does not make a Poll result. - Bind the menus to the same hotkey only after each one works independently in its intended editor.
The test is deliberately local to the active area. A Geometry Nodes editor open elsewhere on the screen does not make the menu eligible under the cursor.
Pitfalls
C.area.type == "NODE_EDITOR"is too broad: it cannot distinguish Geometry Nodes from Shader Editor.- Keep the
C.areaguard so the Poll fails closed when no Blender area is available. - A Poll only decides whether the menu is available. Its commands still need their own valid Blender context.
- Python needs ordinary quote characters (
"or'); smart quotes copied from formatted text cause a syntax error. - Keep a general Node Editor menu without this Poll when some tools really are shared.
Related
- Choose between a Command branch, Poll-gated items, or a Custom control
- Route one trigger to the right menu for its context