Nodes/Avatar Graph/Object Mode Set
ComfyUI Node

Object Mode Set

Switch an object into edit, pose, sculpt, or paint mode

By avatechai·Created 3 years ago·Updated 2 years ago· 264
Object Mode Set
  • BPY_OBJ
  • BPY_OBJ
mode
togglefalse

Blender objects aren't always in "object mode." Mesh editing happens in edit mode, armatures pose in pose mode, sculpting in sculpt mode - and a huge number of Blender operators only work in the mode they belong to. Object_ModeSet wraps bpy.ops.object.mode_set(), the operator that switches the active object's mode, and it's the quiet enabler behind most of the Mesh_ and Object_ nodes in Avatar Graph.

Why you need it explicitly: several other nodes in this pack already switch modes for you under the hood (the edit-mode nodes enter and leave edit mode automatically). But when you're building a graph that mixes operations - say, Object_ModifierApply followed by weight-paint work, or a sculpt pass before shape-key creation - you sometimes need to force the mode yourself so the next operator lands in the right context. That's this node's whole job.

The mechanism. The node sets your BPY_OBJ as active and calls mode_set with your chosen mode. If toggle is on, an object already in that mode switches out of it - handy for building flip-flop graph logic. The mode enum is the full Blender list: OBJECT, EDIT, POSE, SCULPT, VERTEX_PAINT, WEIGHT_PAINT, TEXTURE_PAINT, PARTICLE_EDIT, the grease-pencil modes, and SCULPT_CURVES.

Inputs.

  • BPY_OBJ - the object to switch.
  • mode - the target mode, from the 14-item enum.
  • toggle - off by default; on makes it flip between the mode and object mode.

Output. BPY_OBJ, passed through unchanged. Mode is a context property, not part of the object data you export.

Installing it. Part of Avatar Graph. ComfyUI Manager → "Avatar Graph", or:

cd ComfyUI/custom_nodes
git clone https://github.com/avatechai/avatar-graph-comfyui
cd avatar-graph-comfyui
python -m pip install -r requirements.txt

Restart with --enable-cors-header; the pack pins bpy==3.6.0, so Python 3.10.x is required.

Troubleshooting. Most "operator not allowed in current mode" errors in this pack trace back to a missing mode step - the fix is usually an Object_ModeSet before the failing node. If you set mode to EDIT and the next node still complains, remember that edit-mode nodes in this pack auto-return to object mode when they finish, so the mode you set may not persist the way you expect. And if you're not doing anything mode-sensitive, you can skip this node entirely - it's a prerequisite, not a result.

Categoryblender

Inputs (3)

NameTypeDefaultDescription
BPY_OBJoptBPY_OBJ
modeoptCOMBO14 options: OBJECT, EDIT, POSE, SCULPT, VERTEX_PAINT, WEIGHT_PAINT, +8
toggleoptBOOLEANfalse

Outputs (1)

NameTypeDescription
BPY_OBJBPY_OBJ