Nodes/Avatar Graph/Object Vertex Group Sort
ComfyUI Node

Object Vertex Group Sort

Sorting Vertex Groups by Name or Bones

By avatechai·Created 3 years ago·Updated 2 years ago· 264
Object Vertex Group Sort
  • BPY_OBJ
  • BPY_OBJ
sort_type

By the time you've built an avatar in Avatar Graph you've created, copied, and renamed enough vertex groups that the list looks like it was generated by a random number generator. Object Vertex Group Sort is the tidy-up node: it reorders the groups on the incoming mesh, either alphabetically by name or to match the armature's bone hierarchy.

Order isn't just cosmetic. Some importers and downstream tools assume a particular group order, and a sorted list is dramatically easier to debug when a group index goes wrong.

How it works

An auto-generated wrapper around Blender's bpy.ops.object.vertex_group_sort. One real input:

  • sort_type - NAME sorts groups alphabetically. BONE_HIERARCHY reorders them to mirror the hierarchy of the armature the mesh is bound to.

BONE_HIERARCHY is the one with teeth. If your mesh is parented to an armature (say, via Object Vertex Parent Set), sorting by bone hierarchy gives you an order that matches how the rig is organized, which is what a lot of pipelines want before export. If there's no armature relationship, it'll fall back to doing very little - so NAME is the safe general-purpose pick.

Output is the same BPY_OBJ, so it slots in right before the final export steps.

Installing it

It's part of Avatar Graph:

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 ComfyUI, or install "Avatar Graph" from ComfyUI Manager. Pack-wide install notes: bpy==3.6.0 needs Python 3.10 (README suggests a dedicated conda env), and bpy is a several-hundred-MB headless Blender.

Common issues

The main gotcha is expecting BONE_HIERARCHY to do something on a mesh with no armature. It's hierarchical - no hierarchy, no reordering. If you sort and "nothing changed," check whether you picked the right sort type for your rig state.

And the pack's standing rule: this only works on a real BPY_OBJ from upstream mesh nodes like Create Mesh Layer or Join Meshes. Wire nothing in, sort nothing out.

Categoryblender

Inputs (2)

NameTypeDefaultDescription
BPY_OBJoptBPY_OBJ
sort_typeoptCOMBO2 options: NAME, BONE_HIERARCHY

Outputs (1)

NameTypeDescription
BPY_OBJBPY_OBJ