LazyCaseSwitch (obvpm):
The LazyCaseSwitch node is designed to streamline decision-making processes within a node-based workflow by selecting one of several branches based on a specified name rather than a boolean condition. This node is particularly beneficial for scenarios where you need to dynamically choose between multiple paths, as it allows you to define case names and select the appropriate branch to execute based on the input. The node is "lazy," meaning that only the selected branch is executed, which optimizes performance by skipping the execution of unselected branches and their upstream processes. This feature is especially useful in complex workflows where efficiency and resource management are crucial. By using LazyCaseSwitch, you can create more flexible and efficient workflows that adapt to varying conditions without unnecessary computation.
LazyCaseSwitch (obvpm) Input Parameters:
selected
The selected parameter is a string that specifies the name of the branch to be executed. It is crucial for determining which branch of the workflow will run. If the name provided in selected matches one of the case names, the corresponding branch is executed. There is no default value, and it must be set to a valid case name to ensure proper execution.
cases
The cases parameter is a multiline string input where you list the names of the branches, one per line. These names are used to match against the selected parameter to determine which branch to execute. The list of case names is dynamically filled based on the connected branches, and it is essential for defining the possible paths the node can take. There is no default value, and it should be populated with meaningful branch names to ensure the node functions correctly.
fallback
The fallback parameter is an optional input that provides an output when no case line matches the selected parameter. It is lazy, meaning it only executes if selected, and can be left unconnected if not needed. This parameter is useful for handling cases where the selected name does not match any of the defined case names, ensuring that the node can still produce an output.
on_case_1, on_case_2, ..., on_case_16
These parameters represent the potential branches that can be executed when the selected parameter matches the corresponding case name. Each on_case_n is lazy and only executes if its case line is selected. They are optional and can be left unconnected if not needed. These parameters allow you to define up to 16 different branches, providing flexibility in handling various conditions within your workflow.
LazyCaseSwitch (obvpm) Output Parameters:
value
The value output parameter represents the result of the executed branch. If the selected parameter matches a case name, the corresponding branch's output is returned as value. If no match is found and a fallback is provided, the fallback output is returned. If neither a match nor a fallback is available, the output is None. This parameter is crucial for passing the result of the decision-making process to subsequent nodes in the workflow.
LazyCaseSwitch (obvpm) Usage Tips:
- Ensure that the
selectedparameter is set to a valid case name to avoid unexpected results orNoneoutputs. - Populate the
casesparameter with meaningful and distinct names to clearly define the possible branches and improve the readability of your workflow. - Utilize the
fallbackparameter to handle cases where theselectedname does not match any defined case names, ensuring that your workflow can continue without interruption. - Take advantage of the lazy execution feature to optimize performance by only executing the necessary branches and skipping unselected ones.
LazyCaseSwitch (obvpm) Common Errors and Solutions:
"LazyCaseSwitch: '<selected>' matches no case line and no fallback is connected; outputting None"
- Explanation: This error occurs when the
selectedparameter does not match any of the defined case names in thecasesparameter, and nofallbackis connected to provide an alternative output. - Solution: Verify that the
selectedparameter is set to a valid case name listed in thecasesparameter. If necessary, connect afallbackto ensure an output is produced even when no match is found.
