commit 230d6f5eb08b3839f210dbe531402b2d24fabe5f Author: t22m003 Date: Sat Dec 6 20:33:29 2025 +0900 Initial commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..8b55f8e --- /dev/null +++ b/README.md @@ -0,0 +1,26 @@ + +# ComfyUI Loop Node + +Custom node that provides loop (for-loop) functionality in ComfyUI. +This allows you to repeat execution steps by outputting a list of integers, which triggers ComfyUI's list execution behavior. + +## Features + +- **For Loop (Count)**: Simple loop that runs `N` times. outputs `0` to `N-1`. +- **For Loop (Range)**: Loop based on python `range(start, stop, step)`. + +## Installation + +Navigate to your `ComfyUI/custom_nodes/` directory and clone this repository: + +```bash +git clone https://github.com/t22m003/ComfyUI_LoopNode.git +``` + +## Usage + +Found under the category: `Loop` + +## Sponsor + +[![Sponsor](https://img.shields.io/badge/Sponsor-t22m003-red)](https://github.com/sponsors/t22m003) diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..1e0ea57 --- /dev/null +++ b/__init__.py @@ -0,0 +1,12 @@ + +from .loop_node import SimpleForLoop, SimpleForLoopRange + +NODE_CLASS_MAPPINGS = { + "SimpleForLoop": SimpleForLoop, + "SimpleForLoopRange": SimpleForLoopRange, +} + +NODE_DISPLAY_NAME_MAPPINGS = { + "SimpleForLoop": "For Loop (Count)", + "SimpleForLoopRange": "For Loop (Range)", +} diff --git a/__pycache__/__init__.cpython-312.pyc b/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..8bd2e1d Binary files /dev/null and b/__pycache__/__init__.cpython-312.pyc differ diff --git a/__pycache__/loop_node.cpython-312.pyc b/__pycache__/loop_node.cpython-312.pyc new file mode 100644 index 0000000..76c18ef Binary files /dev/null and b/__pycache__/loop_node.cpython-312.pyc differ diff --git a/loop_node.py b/loop_node.py new file mode 100644 index 0000000..9037ecd --- /dev/null +++ b/loop_node.py @@ -0,0 +1,45 @@ + +class SimpleForLoop: + def __init__(self): + pass + + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "total": ("INT", {"default": 1, "min": 1, "max": 100, "step": 1}), + } + } + + RETURN_TYPES = ("INT",) + RETURN_NAMES = ("index",) + OUTPUT_IS_LIST = (True,) + FUNCTION = "execute" + CATEGORY = "Loop" + + def execute(self, total): + return (list(range(total)),) + +class SimpleForLoopRange: + def __init__(self): + pass + + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "start": ("INT", {"default": 0, "min": 0, "max": 10000, "step": 1}), + "stop": ("INT", {"default": 10, "min": 0, "max": 10000, "step": 1}), + "step": ("INT", {"default": 1, "min": 1, "max": 10000, "step": 1}), + } + } + + RETURN_TYPES = ("INT",) + RETURN_NAMES = ("index",) + OUTPUT_IS_LIST = (True,) + FUNCTION = "execute" + CATEGORY = "Loop" + + def execute(self, start, stop, step): + range_vals = list(range(start, stop, step)) + return (range_vals,)