Nodes/Avatar Graph/Object Gpencil Modifier Move To Index
ComfyUI Node

Object Gpencil Modifier Move To Index

Teleport a modifier straight to the slot you want

By avatechai·Created 3 years ago·Updated 2 years ago· 264
Object Gpencil Modifier Move To Index
  • BPY_OBJ
  • BPY_OBJ
modifier
index0

Object_GpencilModifierMoveToIndex moves a grease pencil modifier to an exact position in the stack, no walking required. Where Object_GpencilModifierMoveUp and MoveDown shift things one slot at a time, this node jumps the modifier straight to a named index - slot 0, slot 3, wherever you need it. It wraps Blender's bpy.ops.object.gpencil_modifier_move_to_index, and it's the precise version of the reorder family.

When you'd reach for it

Stack position matters in grease pencil work because modifiers evaluate top to bottom, and the order changes how effects combine. You'll want this node whenever you know where a modifier belongs rather than wanting to shuffle toward it: put the outline at the top, park the time trim at the bottom, keep the noise above the smoothing. It's also the cleanest way to fix the fallout of a copy - copies land at the end of the stack, and one MoveToIndex call parks them exactly where the original used to sit.

How it works

Auto-generated wrapper over the gpencil_modifier_move_to_index operator. It makes your BPY_OBJ active, moves the named modifier to the index you supply, and passes the object back. Inputs:

  • BPY_OBJ (optional) - the grease pencil object.
  • modifier (STRING, default empty) - the name of the modifier to move.
  • index (INT, default 0, 0–2147483647) - the target position. 0 is the top of the stack, the first to evaluate.

Output: BPY_OBJ, the same object, with the modifier repositioned.

What "index" means here

Indices count from the top: 0 is the first modifier in the stack, 1 the second, and so on. A few practical notes. If you move a modifier to an index that doesn't exist yet - say, 7 on a stack of three - Blender clamps it to the nearest valid position, usually the bottom. And because this whole family addresses modifiers by name, the usual naming discipline applies: after a copy, the duplicate is Name.001, and you have to type that exactly. There's no list node to query modifier names, so a consistent naming convention is worth its weight here.

One thing to keep in mind: since the index counts from the top, moving one modifier changes the indices of everything below it. If you're scripting a series of MoveToIndex calls, do them in an order that doesn't fight itself - or recompute targets as you go.

Install and gotchas

Standard pack install:

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

or ComfyUI Manager → "Avatar Graph". House rules: Python 3.10 for bpy==3.6.0, ~2.5GB SAM checkpoint + mediapipe models on first load, scene resets every run (so the whole stack is rebuilt each execution), live preview needs --enable-cors-header.

Object_GpencilModifierMoveToIndex is the node that turns "arrange my modifier stack" from a shuffle into a command. If you already know exactly where a modifier belongs, this is the one you reach for instead of nudging it along slot by slot.

Categoryblender

Inputs (3)

NameTypeDefaultDescription
BPY_OBJoptBPY_OBJ
modifieroptSTRING
indexoptINT00–2147483647

Outputs (1)

NameTypeDescription
BPY_OBJBPY_OBJ