Nodes/Avatar Graph/Object Material Slot Select
ComfyUI Node

Object Material Slot Select

Select every face that uses the active material

By avatechai·Created 3 years ago·Updated 2 years ago· 265
Object Material Slot Select
  • BPY_OBJ
  • BPY_OBJ

Sometimes you need to grab "everything made of hair" and the fastest way is to let the material do the selecting for you. Object_MaterialSlotSelect wraps bpy.ops.object.material_slot_select(), which selects every vertex or face assigned to the active material slot of the active object. In Blender you'd reach for this in the material slot panel; here you get it as a node in a ComfyUI graph.

This one is genuinely handy in Avatar Graph, because the pack's whole construction method is material-driven. You segment a character image, build mesh layers, and each layer ends up with its own material. That means the material assignment is your region mask. Need to isolate the face for a shape-key edit? Select the face material, then run your edit. Want to re-apply a texture or a modifier to just the eyes? Material-select first, then do the operation. The selection carries forward in the hidden Blender scene to the next node that respects it.

The mechanism. The node sets your BPY_OBJ as the active object and calls the operator, which inspects the active slot and toggles on selection for every element bound to it. No parameters besides the object itself - the "which material" decision is entirely determined by what's active on the object. As with its sibling Object_MaterialSlotDeselect, this node changes only selection state; the mesh data and the BPY_OBJ output are untouched.

Inputs.

  • BPY_OBJ - the object whose active material slot's faces get selected.

Output. BPY_OBJ, passed through so the graph keeps flowing.

Installing it. Ships in Avatar Graph. Install from ComfyUI Manager (search "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 for the live preview; the pack requires Python 3.10.x because of bpy==3.6.0.

Troubleshooting. The usual letdown is picking the wrong active slot and selecting the wrong region - double-check what's active on the object before you run it. Also, selection state is invisible to you in the ComfyUI UI; the pack's preview or a later node that surfaces selection is the only way to confirm it worked. If it seems dead, the active slot may have zero assigned elements. It's a small node with a clear job: make materials do the boring selecting, so you don't have to.

Categoryblender

Inputs (1)

NameTypeDefaultDescription
BPY_OBJoptBPY_OBJ

Outputs (1)

NameTypeDescription
BPY_OBJBPY_OBJ