Object Material Slot Move
Reorder material slots the way Blender's list does
- BPY_OBJ
- BPY_OBJ
Material slots aren't just a list - their order matters. Slot zero is the one that shows up first in the shader, the one weight-paint and export tools treat as default. Object_MaterialSlotMove wraps bpy.ops.object.material_slot_move(), the operator behind the up/down arrows in Blender's material slot list, and it does exactly one thing: moves the active material slot of the active object up or down one position.
In an avatar workflow this is a finishing touch, not a foundation. Once your character mesh has its materials assigned, you often want a predictable slot order before exporting - the base body texture first, the details after - because downstream tools and the Avatech Shape Flow treat slot order as meaningful. Move the active slot to where it belongs, one click at a time. If you need something higher than a single step, chain two of these or use the Object_MaterialSlotRemoveUnused node to prune the list first.
The mechanism. The node sets BPY_OBJ as active and calls the operator with your direction. The only real control is direction, an enum with two values: UP and DOWN. Straightforward pass-through of the Blender operator, no surprises.
Inputs.
BPY_OBJ- the object whose material slot list you're reordering.direction-UPorDOWN. The active slot moves one position in that direction; at the ends of the list it just stops.
Output. BPY_OBJ, passed through unchanged.
Installing it. Part of Avatar Graph. Via 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 for the live preview. Pack pins bpy==3.6.0, which means Python 3.10.x is required.
Troubleshooting. Because the operator acts on the active slot, the usual failure mode is "I moved the wrong one" - make sure the active slot on the object is the one you intend. If the node runs but the order looks unchanged, you were probably already at the top or bottom of the list. It's a small, boring node, and that's fine: material-slot order is exactly the kind of detail that breaks exports quietly, so having it as a repeatable graph step beats redoing it by hand.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| BPY_OBJopt | BPY_OBJ | — | |
| directionopt | COMBO | 2 options: UP, DOWN |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| BPY_OBJ | BPY_OBJ | — |