FromListGet1Mask
Grab one mask out of a mask list by number — FromListGet1Mask
- list
- MASK
The name does what it says: a list of masks goes in, one mask comes out, and you pick which one with an integer. FromListGet1Mask is the "fetch by index" cousin of Bmad's FromListGetMasks, and it exists because lists are the boring backbone of batch ComfyUI work. Most nodes want exactly one mask - one mask for a conditioning set area, one mask for a composite, one mask into a VAE encode - and a list refuses to plug into those sockets. This node is the bridge.
It's part of the Bmad/Lists/Get1 family in the comfyui_bmad_nodes pack, which is the same pack that gives you ToMaskList, ToImageList, ToStringList and the rest. You'll usually pair it with one of those: ToMaskList gathers N individual masks into a list, this node pulls one back out. The classic shape is a mask-compositing workflow where you generate a pile of candidate masks (say from Color Clip or a grab cut node), bundle them, and then either index through them manually or feed the index from a random int node to shuffle which region gets used.
How it works
Under the hood it's tiny. The node uses a shared metaclass with INPUT_IS_LIST set, so ComfyUI hands it the whole list as one value. The one line that matters:
index = index % len(list)
return (list[index],)
That modulo is the whole personality of this node. Index 0 is the first mask, but index -1 is the last, -2 the second-to-last, and anything out of range wraps around instead of erroring. Index 5 on a three-item list silently gives you item 2. That's deliberate - it means you can drive the index with a stepped or random int node and never bother with bounds checks. It also means "index out of range" is not a failure mode here; the only way to break it is to feed an empty list.
Inputs and outputs
Two inputs, one output:
list- a MASK list, markedforceInput, so there's no widget; you have to wire it from a list-producing node likeToMaskListorExtendMaskList.index- an INT, default0, range down to-2147483648to leave room for negative indexing.- Output: one MASK, ready to plug into whatever expects a single mask.
Install
This ships in the bmad4ever/comfyui_bmad_nodes pack. Easiest via ComfyUI Manager: search "comfyui_bmad_nodes" (the pack shows as "Bmad Nodes"), install, restart. Or do it by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/bmad4ever/comfyui_bmad_nodes
cd comfyui_bmad_nodes
pip install -r requirements.txt
Then restart ComfyUI. There are no model downloads - the requirements are just opencv-python, scikit-image, simpleeval and gray2color. opencv-python is the chunky one (it's a big wheel), but it's a one-time install.
Common issues
The classic mistake is expecting the index to clamp. It doesn't - it wraps. If you want to guarantee item 3 of a list that might shrink, compute your own bound first. And remember the list input won't accept a plain mask: it needs an actual list connection, so if the socket stays empty, the node can't run. Beyond that this is a two-input utility; there isn't much left to go wrong.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| list | MASK | — | |
| index | INT | 0 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MASK | MASK | — |