Nodes/Avatar Graph/Object Material Slot Remove
ComfyUI Node

Object Material Slot Remove

Deleting the active material slot in Avatar Graph

By avatechai·Created 3 years ago·Updated 2 years ago· 264
Object Material Slot Remove
  • BPY_OBJ
  • BPY_OBJ

The direct counterpart to Object Material Slot Add, and worth not confusing with Object Material Slot Remove Unused elsewhere in this pack: Object Material Slot Remove deletes one specific slot - the currently active one - regardless of whether anything on the mesh actually uses it. It's a targeted removal, not a cleanup sweep.

How it works

This wraps Blender's object.material_slot_remove operator. Every material slot an object holds can be referenced by faces on the mesh, and this removes whichever slot is currently active in the object's material list - the same as selecting a slot in Blender's Material Properties tab and hitting the - button. If faces on the mesh were assigned to that slot, they don't get deleted or reassigned automatically to a "safe" slot in any special way beyond however Blender's own removal handles index shifting - worth checking the result if a specific region was relying on that slot's material.

The inputs and outputs that matter

There's exactly one input:

  • BPY_OBJ - the object to remove the active slot from.

Output is a single BPY_OBJ, the same object with one fewer material slot.

How to install it

ComfyUI Manager, search "Avatar Graph" and install, or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/avatechai/avatar-graph-comfyui

then pip install -r requirements.txt and restart. Needs Blender's bpy module, pinned to Python 3.10.x - a dedicated conda environment on macOS/Linux, or Avatech's prebuilt Python-3.10 ComfyUI zip on Windows with the pack installed through Manager afterward.

Common issues & troubleshooting

If the node fails to load, that's the pack's Python-version pin, not this operator - check the ComfyUI console at startup for an import error and confirm a clean Python 3.10.x environment with requirements.txt installed cleanly.

The one to watch for: this removes the active slot, and this node gives you no way to name or index which slot that is - it depends entirely on what was left active by whatever ran before it in your graph. If a material disappears from the object that you didn't mean to touch, that's almost certainly the wrong slot being active going in, not a problem with this node's logic. If your actual goal is stripping out slots nothing on the mesh references anymore - say, leftovers after a join - reach for Object Material Slot Remove Unused instead; it checks face usage and only removes what's genuinely unused, rather than removing whatever happens to be active.

There's also a re-indexing effect worth knowing about if you're removing slots in sequence: Blender shifts every slot after the removed one down by one index to close the gap. If something later in your graph, or a face's material-index assignment set earlier, refers to slots by number rather than by name, removing one slot can silently change which material a different, unrelated set of faces ends up rendering with. That's not a bug in this node - it's how Blender's slot list has always worked - but it's the kind of thing that only shows up as "the wrong material appeared somewhere else" well downstream of where the actual removal happened, which makes it worth checking first whenever an unrelated part of the mesh looks off after this node runs.

Categoryblender

Inputs (1)

NameTypeDefaultDescription
BPY_OBJoptBPY_OBJ

Outputs (1)

NameTypeDescription
BPY_OBJBPY_OBJ