Nodes/Avatar Graph/Object Link To Collection
ComfyUI Node

Object Link To Collection

Organize your avatar's parts into Blender collections without leaving the graph

By avatechai·Created 3 years ago·Updated 2 years ago· 264
Object Link To Collection
  • BPY_OBJ
  • BPY_OBJ
collection_index-1
is_newfalse
new_collection_name

Object_LinkToCollection wraps Blender's bpy.ops.object.link_to_collection, which moves the selected objects into a different collection. If you've ever had a Blender scene where everything ends up in one giant pile - and in Avatar Graph's headless Blender, that's the default - this is how you file your avatar's parts into named collections from inside the graph.

For the avatar pipeline this is more useful than it sounds. You're building mesh layers for eyes, mouth, and body out of segmented images, and they all land in the same scene. A LinkToCollection node after each mesh-layer node gives you a tidy scene structure: Eyes, Mouth, Body. That organization carries straight into what you export and what you debug in the live preview, and it keeps the rigging logic readable when the graph starts to sprawl.

The inputs that matter

  • BPY_OBJ (optional) - the object to move. Unwired, it acts on the active object.
  • collection_index - which existing collection to move into. Leave it at -1 unless you know the index; the node is much more predictable when you create a new collection instead.
  • is_new - tick this to create a brand-new collection.
  • new_collection_name - the name used when is_new is on. This is the one you'll actually type.

So the beginner-friendly recipe is: set is_new to true, type a name like "Mouth", wire in the object. Blender creates the collection, moves the object, and you get the same BPY_OBJ back to continue the chain.

Gotchas

Index-based collection targeting is the fiddly part. collection_index refers to the order collections exist in the scene, which shifts as you create and delete them - that's why the recommended path is is_new + a name, which is stable. Also note this moves the object to the new collection rather than just linking it to an additional one, which is Blender semantics and worth remembering if you expected the object to stay in both places.

Installation

Avatar Graph requires Python 3.10.x - the bpy==3.6.0 dependency only ships 3.10 wheels. Install via ComfyUI Manager (search "Avatar Graph") or:

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

Restart with --enable-cors-header for the live preview. First launch auto-downloads the SAM model (~2.4 GB) and mediapipe landmarkers, so don't panic at the boot time. If you run without --enable-cors-header, you can still export a .GLB from Avatar Main Output and check your collection layout in real Blender.

Categoryblender

Inputs (4)

NameTypeDefaultDescription
BPY_OBJoptBPY_OBJ
collection_indexoptINT-1-1–2147483647
is_newoptBOOLEANfalse
new_collection_nameoptSTRING

Outputs (1)

NameTypeDescription
BPY_OBJBPY_OBJ