# Acknowledgments / AI Disclosure This project was built with the assistance of Gemini for code generation. All AI-generated outputs have been verified and reviewed by the author to ensure technical accuracy and functionality. # ComfyUI-IterSwitch A set of dynamic switch nodes for ComfyUI, designed to simplify complex workflows by allowing flexible, iterative input selection. These nodes provide dynamic connection management and intelligent fallback logic. ## Key Features Dynamic Inputs: Automatically resizes the number of input connections based on the input_count widget. ## Smart Fallback: With the use_last_input option enabled, the node can search backwards from the current index to find the nearest valid (connected) input, ensuring a result is always returned. ## Type Support: Includes switches for Text, Conditioning, CLIP, Image, Model, and Float types. ### Example Usage: Iter_TextSwitch The Iter_TextSwitch node allows you to combine a base string with one of many dynamically connected inputs. 1. Basic Connection The node takes an add_text input (base string) and allows you to dynamically define multiple text inputs. You can select the specific input using output_index. ![text switch sample](assets/example_iterTextSwitch01.png) *Example using [waiIllustrious v16](https://civitai.com/models/827184?modelVersionId=2514310)* 2. Fallback Logic When use_last_input is enabled, the node becomes more robust. If your current output_index points to a disconnected or empty input, the node will automatically search backwards through your inputs until it finds the most recent valid (connected) string. ![will use last valid input if use_last_input checked](assets/example_iterTextSwitch02.png) *Example using [waiIllustrious v16](https://civitai.com/models/827184?modelVersionId=2514310)* 3. Iterative Workflow By using the output_index, you can easily integrate this node into iterative loops, ensuring that your text prompts are dynamically selected or concatenated based on your workflow state. ![text switch sample2](assets/example_iterTextSwitch03.png) *Example using [waiIllustrious v16](https://civitai.com/models/827184?modelVersionId=2514310)* ## Installation Navigate to your ComfyUI custom_nodes directory. Run: Bash `git clone https://github.com/younger15/ComfyUI-IterSwitch.git` Restart ComfyUI.