Nodes/ComfyUI-JDCN/LogicUtil_Yieldable (Sequential) Iterator Int
ComfyUI Node

LogicUtil_Yieldable (Sequential) Iterator Int

A sequential counter that hands you the next number on every run

By daxcay·Created 2 years ago·Updated about a year ago· 159
LogicUtil_Yieldable (Sequential) Iterator Int
    • INT
    start0
    end10
    step1
    reset0

    If a random node is "roll the dice," this one is "count to ten, one per turn." LogicUtil_Yieldable (Sequential) Iterator Int is a stateful counter from the LogicUtil subpack of ComfyUI-JDCN: each time you run the workflow it hands you the next number in a range, and when it reaches the end it wraps back around and starts over. It's the node for batch jobs that need to step through values instead of guessing them.

    What it's supposed to do

    You set start (default 0), end (default 10), and step (default 1). On the first run it starts at start, and every subsequent run increments by step until it passes end, at which point it wraps to start and keeps going. The reset input (an INT, 0 or 1) restarts it from the beginning.

    The intended uses are obvious once you see it: step a seed through a range so each run of a batch gets a distinct, ordered seed; walk an index through a list of prompt variants one at a time; drive a parameter sweep where run 1 uses value 1, run 2 uses value 2, and so on. It's the deterministic cousin of the pack's random int node - instead of rolling a number, it counts.

    The catch you should know about

    I read the source so you don't have to, and the implementation has a wrinkle. The iterator is stored as a range object and pulled with next() - but a range in Python is iterable, not an iterator, and calling next() on it raises a TypeError. In the version I checked (both the snapshot and the current main branch), the first next() call can error out rather than yield your start value. It may well be patched by the time you read this - it's a two-line fix - but if this node throws a 'range' object is not an iterator error, that's why, and it's not something you configured wrong.

    Even when it behaves, two more things to keep in mind. It's stateful: the current position lives on the node between runs, so re-running with the same settings continues the count rather than restarting it - use reset when you want a clean slate. And since it only emits one value per run, it's built for workflows that are queued multiple times, not for producing a whole range in a single pass.

    Installing it

    It's part of ComfyUI-JDCN. ComfyUI Manager: Install Custom Nodes → search "JDCN", install, restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/daxcay/ComfyUI-JDCN.git
    cd ComfyUI-JDCN
    pip install -r requirements.txt
    

    Only dependency is piexif; no models to download. The pack is a small two-person hobbyist effort (Daxton Caylor and Jerry Davos), and this node shows its rough edges more than its peers. The concept is genuinely useful for batch sweeps - just go in with your eyes open about the statefulness and the range quirk, and check your installed version before relying on it.

    CategoryLogicUtil

    Inputs (4)

    NameTypeDefaultDescription
    startINT00–9999999999
    endINT100–9999999999
    stepINT10–9999999999
    resetINT00–1

    Outputs (1)

    NameTypeDescription
    INTINT