Object Move To Collection
Organizing generated objects into named groups in Avatar Graph
- BPY_OBJ
- BPY_OBJ
Avatar Graph pipelines tend to spawn a lot of objects - segmented layers, extracted meshes, generated primitives - and Blender's scene stays organized (or doesn't) based on which collection each one lives in. Object Move To Collection puts an object into a specific collection, either an existing one by position or a brand-new one you name on the spot.
How it works
This wraps Blender's object.move_to_collection operator, the same one behind the M shortcut in Blender's viewport. In normal, interactive use it pops up a menu letting you pick a target collection or type a new name; run programmatically through a node, you supply that choice directly instead. It unlinks the object from wherever it currently sits and links it into the target collection instead.
The inputs and outputs that matter
BPY_OBJ- the object to move.collection_index(default-1) - which existing collection to target, by Blender's internal ordering. In Blender's own interactive menu this correlates to menu position, so relying on it from a script means knowing your scene's collection order in advance rather than referencing a collection by name.is_new(defaultfalse) - set this to create a brand-new collection instead of targeting an existing one by index.new_collection_name- the name for that new collection, used only whenis_newis on.
Output is a single BPY_OBJ, the same object, now living in the target collection.
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 won't load, that's the pack's Python-version pin, not this operator - check ComfyUI's startup console for an import error and confirm a clean Python 3.10.x environment with requirements.txt installed cleanly.
If the object lands in the wrong collection, the likely cause is collection_index not pointing at what you expected - since collections are targeted by numeric position rather than name here, any change to how many collections exist in the scene (one added or removed by an earlier step in the same run) shifts what a given index actually points to. If you want a predictable, name-driven target every time regardless of what else is in the scene, setting is_new with an explicit new_collection_name is more reliable than depending on collection_index staying stable across runs.
Worth planning for if you're organizing a multi-object avatar build - eyes, mouth, base mesh, props - across several runs of the same graph: calling this with is_new set and the same new_collection_name repeatedly doesn't necessarily reuse the existing collection cleanly every time, depending on how Blender's own operator resolves a name collision versus creating a fresh one. If you're seeing duplicate collections with a numeric suffix piling up after repeated runs, that's the operator creating a new collection each time rather than finding and reusing one with a matching name - something to check for before assuming your graph is broken.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| BPY_OBJopt | BPY_OBJ | — | |
| collection_indexopt | INT | -1-1–2147483647 | — |
| is_newopt | BOOLEAN | false | — |
| new_collection_nameopt | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| BPY_OBJ | BPY_OBJ | — |