Mie Loop Get Index ๐
Read the current iteration number anywhere in the loop
- 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 is0, second is1, 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.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| loop_ctx | MIE_LOOP_CTX | โ |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| index | INT | โ |