Nodes/Avatar Graph/Object Hook Add Newob
ComfyUI Node

Object Hook Add Newob

Creating a Blender hook empty without leaving ComfyUI

By avatechai·Created 3 years ago·Updated 2 years ago· 264
Object Hook Add Newob
  • BPY_OBJ
  • BPY_OBJ

Hooks are one of those Blender features that solve problems nobody names until they hit them: you want a chunk of a mesh - hair strands, a ponytail, an antenna - to follow a bone or an empty without building a whole weight-paint setup. A hook modifier grabs a set of vertices and lets another object drag them around. Object_HookAddNewob is the "add a new empty as the hook" operator, exposed as a node in the Avatar Graph pack.

Why does that matter here? Avatar Graph's whole game is rigging 2.5D characters inside ComfyUI by embedding a real Blender scene. Hair and accessories on anime avatars are classic hook territory: you select the verts, hook them to an empty, parent the empty to the head bone, and the hair moves when the head turns - no weight painting required.

How it works

This node calls bpy.ops.object.hook_add_newob() on the object you feed in. In Blender that operator does two things at once: it adds a Hook modifier to the mesh and spawns a brand-new empty object as the hook target, positioned at the averaged center of whatever is selected. What gets hooked depends on selection, which is the part that trips people up.

The BPY_OBJ input sets the active object in the embedded scene and passes back out untouched - same pass-through convention as every Object_* node in this pack. The empty it creates isn't returned by the node; it lives in the embedded scene's object list, ready to be grabbed by other nodes (or by the Avatech editor) once you know its name.

The catch: in Blender, hook_add_newob is an edit-mode operator. You want the mesh in edit mode with the vertices you care about selected before this runs. The Avatar Graph pack has Mesh_* edit-mode nodes for that, so a realistic chain is: load the mesh layer → Mesh_Select the target verts → Object_HookAddNewob. If you run it in object mode with nothing selected, Blender hooks the whole object, which is rarely what you wanted.

Inputs and outputs

Just two things to know about:

  • BPY_OBJ (input) - the mesh you're hooking. Sets it active, and it's what comes back out.
  • BPY_OBJ (output) - the same object, so you can keep wiring downstream.

No other knobs. The empty's size, name, and so on are Blender defaults; if you need to control them, follow this with the pack's object-setter nodes.

Installing it

Part of the Avatar Graph pack. Easiest via ComfyUI Manager (search "Avatar Graph"), or manually:

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

The pack pins bpy==3.6.0, so your ComfyUI Python needs to be 3.10.x - anything newer and bpy won't build, and the whole pack goes missing from your node list. First launch also auto-downloads the SAM ViT-H checkpoint (~2.5 GB) into models/sams plus MediaPipe landmarkers, so budget some time and disk. The README suggests running ComfyUI with --enable-cors-header for the live avatar preview.

Common issues

The classic failure is "I hooked it but nothing moves." That's usually one of two things: you ran it in object mode so the whole mesh got hooked (and there's no empty/bone relationship driving it yet), or the empty is just sitting there with nothing parenting it to a bone. Remember this pack is labeled a work-in-progress - the README openly says nodes and templates are still changing - so if an operator behaves oddly, check the repo for updates before assuming you did it wrong.

Categoryblender

Inputs (1)

NameTypeDefaultDescription
BPY_OBJoptBPY_OBJ

Outputs (1)

NameTypeDescription
BPY_OBJBPY_OBJ