Conditions — Show/Hide Based on Context¶
Conditions let a menu or button appear only when certain requirements are met.
- Pie-level condition — if not met, the shortcut does nothing (the menu doesn't open).
- Button-level condition — if not met, the button is hidden inside the menu.
This lets you build context-aware menus that only show relevant tools. For example, a modeling pie that hides sculpt-only buttons when you're not in Sculpt Mode.
How to Write a Condition¶
Type a single-line Python expression in the Condition field. It must return True or False.
Available variables: context, bpy.
# Show only in Object Mode
context.mode == 'OBJECT'
# Show only in Edit Mode with a Mesh
context.mode == 'EDIT_MESH'
# Show only when an object is selected
bool(context.active_object)
# Show only when a Mesh object is selected
bool(context.active_object) and context.active_object.type == 'MESH'
# Show only in Sculpt Mode
context.mode == 'SCULPT'
One line only
The condition must fit on a single line. For complex logic, combine with and, or, and parentheses.
Common Conditions Reference¶
| Goal | Expression |
|---|---|
| Only in Object Mode | context.mode == 'OBJECT' |
| Only in Edit Mode (Mesh) | context.mode == 'EDIT_MESH' |
| Only in Sculpt Mode | context.mode == 'SCULPT' |
| Only in Pose Mode | context.mode == 'POSE' |
| Only in Weight Paint | context.mode == 'WEIGHT_PAINT' |
| Only with a Mesh selected | bool(context.active_object) and context.active_object.type == 'MESH' |
| Only with an Armature selected | bool(context.active_object) and context.active_object.type == 'ARMATURE' |
| Only with a Camera selected | bool(context.active_object) and context.active_object.type == 'CAMERA' |
| Only with a Light selected | bool(context.active_object) and context.active_object.type == 'LIGHT' |
| Only when something is selected | bool(context.selected_objects) |
| Only when nothing is selected | not bool(context.selected_objects) |
| NOT in Object Mode | context.mode != 'OBJECT' |
| In Object OR Edit Mode | context.mode in ('OBJECT', 'EDIT_MESH') |
Mode Names Reference¶
OBJECT — Object Mode
EDIT_MESH — Edit Mode (Mesh)
EDIT_CURVE — Edit Mode (Curve)
EDIT_SURFACE — Edit Mode (Surface)
EDIT_TEXT — Edit Mode (Text)
EDIT_ARMATURE — Edit Mode (Armature)
EDIT_METABALL — Edit Mode (Metaball)
EDIT_LATTICE — Edit Mode (Lattice)
POSE — Pose Mode
SCULPT — Sculpt Mode
VERTEX_PAINT — Vertex Paint
WEIGHT_PAINT — Weight Paint
TEXTURE_PAINT — Texture Paint
PARTICLE_EDIT — Particle Edit