Nodes/Comfyui-XYZ-stitch/XYZ Grid Input
ComfyUI Node

XYZ Grid Input

One Combo at a Time

By psdwizzard·Created 10 months ago·Updated 10 months ago· 3
XYZ Grid Input
    • x_value
    • y_value
    • z_value
    • x_index
    • y_index
    • z_index
    • total_combinations
    • grid_info
    x_valuesred, blue, green
    y_values1, 2, 3
    z_valuescat, dog, tree
    index0

    Automatic1111 has a built-in XYZ Plot script: type a few comma-separated values per axis, hit generate, and it grinds through every combination and hands you a labeled grid. ComfyUI, famously, doesn't. This whole pack exists to rebuild that idea, and XYZ Grid Input is the brain of it - the node that turns "red, blue, green" × "10, 20, 30" into one specific combination per run.

    Here's the trick that makes it work without any custom samplers: instead of auto-running the whole sweep, ComfyUI queues one generation at a time, and you bump an index widget between runs. XYZ Grid Input does the bookkeeping. Feed it your comma-separated lists, set the index, and it hands you exactly the values for that slot.

    How it works

    Under the hood it's itertools.product on your three parsed lists. Every index maps to one combination, and the mapping order matches what A1111 users expect: X changes fastest, then Y, then Z. So index 0 is the first X with the first Y, index 1 is the second X with the first Y, and so on.

    Two implementation details worth knowing. First, the index wraps around - set it higher than your total combination count and it silently starts over at the beginning instead of erroring. Second, the current combo is recomputed fresh on every run from your widgets, so there's no hidden state to go stale. What you see in the widget is what you get.

    The inputs and outputs that matter

    Only four inputs, all comma-separated strings except the index:

    • x_values, y_values, z_values - your lists. Leave z_values empty for a plain 2D grid; the node treats it as a single dummy value.
    • index - the current combination slot. Start at 0 and increment by 1 for each run in the sweep.

    The outputs are where it earns its keep:

    • x_value, y_value, z_value - the current values as strings. The text goes straight into a prompt node; anything numeric has to pass through the pack's XYZ String to Number node first, because a sampler won't accept "20".
    • x_index, y_index, z_index - where you are in each axis, handy if you're doing something fancy with positioning.
    • total_combinations - wire this to the XYZ Auto Collector so it knows when the sweep is done.
    • grid_info - a human-readable Combination 3/9: X=green, Y=20, Z=... readout you can show with a text node.

    Installing

    The whole pack installs at once - there are no per-node dependencies. Either use ComfyUI Manager (search "XYZ Grid" or "XYZ Stitch") or:

    cd ComfyUI/custom_nodes/
    git clone https://github.com/psdwizzard/Comfyui-XYZ-stitch.git
    

    Restart ComfyUI and the nodes appear under the "XYZ Grid" category. No requirements.txt, no model downloads, no hidden PyAV-style surprises - it's just torch, PIL, and numpy, which ComfyUI already ships.

    Where people get burned

    The #1 beginner mistake is forgetting to bump the index and staring at the same image nine times. Set index 0, queue, set index 1, queue, and so on - that's the whole workflow. The second gotcha is expecting the node to drive anything automatically. It's a pure function of its widgets; the "automation" lives in the collector and stitch nodes downstream, not here. And because it's a string node by design, don't try to feed y_value straight into a KSampler's steps input. The String to Number node is not optional, it's the adapter.

    CategoryXYZ Grid

    Inputs (4)

    NameTypeDefaultDescription
    x_valuesSTRINGred, blue, greenComma-separated values for X axis
    y_valuesSTRING1, 2, 3Comma-separated values for Y axis
    z_valuesSTRINGcat, dog, treeComma-separated values for Z axis (leave empty to disable)
    indexINT00–10000Current combination index (use 0 to start, increment for each run)

    Outputs (8)

    NameTypeDescription
    x_valueSTRING
    y_valueSTRING
    z_valueSTRING
    x_indexINT
    y_indexINT
    z_indexINT
    total_combinationsINT
    grid_infoSTRING