Nodes/ComfyUI_MieNodes/Mie Loop Get Index ๐Ÿ‘
ComfyUI Node

Mie Loop Get Index ๐Ÿ‘

Read the current iteration number anywhere in the loop

By MieMieeeeeยทCreated 2 years agoยทUpdated 27 days agoยท 225
Mie Loop Get Index ๐Ÿ‘
  • loop_ctx
  • index

A small, honest utility. Inside a MieNodes loop, MieLoopGetIndex pulls the current iteration number out of the loop context and hands it to you as a plain INT. That's the whole job. It's the "which pass am I on?" node.

Part of ComfyUI-MieNodes (ComfyUI_MieNodes), MieMieeeee's utility pack, under the ๐Ÿ‘ Loop submenu. It only makes sense between a MieLoopStart and a MieLoopEnd.

Why you'd reach for it

MieLoopStart already emits an index output, but that's only available right at the top of the loop. Once you're deep in the body - several nodes downstream, past a branch, inside a subgraph - the only thing you're reliably carrying is the loop_ctx. GetIndex lets you crack that context open wherever you are and get the index back out, without running a wire all the way from Start.

Typical uses: building a filename that includes the iteration number (frame_0.png, frame_1.png, โ€ฆ), feeding the index into a seed so each pass is deterministic-but-different, or printing progress. Anywhere you'd want "the loop counter" as a number, this is it.

The inputs and outputs that matter

One input, one output - nothing to configure:

  • loop_ctx (MIE_LOOP_CTX) - the context from Start (or from any body node that passes it along).
  • index (INT) - the 0-based position of the current pass. First iteration is 0, second is 1, and so on.

Zero-based matters. If you're building human-facing labels ("image 1 of 5") you'll want to add one; if you're indexing into a list or seeding, zero-based is usually what you want as-is.

Installing it

ComfyUI Manager โ†’ search ComfyUI-MieNodes โ†’ install โ†’ restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/MieMieeeee/ComfyUI-MieNodes

then restart. No model downloads or heavy dependencies for the loop nodes. Find it under ๐Ÿ‘ MieNodes โ†’ ๐Ÿ‘ Loop.

Common issues

It errors or gives garbage outside a loop. GetIndex needs a real loop_ctx from a live loop. It's not a general-purpose counter - drop it between a Start and an End, not on its own.

Off-by-one in my filenames. The index is 0-based. If your first output is landing as ..._0 and you wanted ..._1, add one to the index before you use it. That's expected, not a bug.

I need first/last, not a raw number. If all you actually want is "is this the first pass" or "the last pass," the dedicated MieLoopIfIsFirst and MieLoopIfIsLast nodes are cleaner than comparing the index yourself. For arbitrary comparisons, MieLoopIfCurrentIdx does the ==/</> test in one node.

Category๐Ÿ‘ MieNodes/๐Ÿ‘ Loop

Inputs (1)

NameTypeDefaultDescription
loop_ctxMIE_LOOP_CTXโ€”

Outputs (1)

NameTypeDescription
indexINTโ€”