Forgive me if this has already been discussed. I look but couldn’t find anything similar.
I’ve had several if statements in code blocks that have been giving me warnings that only pertain to the portion of the statement that shouldn’t be running. I try to say if condition is true, do THIS, else do THAT. Then when the condition is false I expect it to only do THAT. Well, it does do THAT, but it also gives me a warning that it can’t do the THIS because of the condition. And usually, I know that it can’t do the THIS on false conditions, and that’s why I am trying to make an if statement.
An example would demonstrate this better. In the image below, I try to get the first 31 characters if a string if the input string is greater than 31 characters. Otherwise, I want the output to equal the input. I pass a 13 character string through the node and it outputs the 13 character string like it’s supposed to, but it also tells me that it can’t get the first 31 characters of the string. I want to tell it, “yes, but I’m not asking you to…” but I don’t know how to communicate this to Dynamo. If I disconnect the node, run the graph, reconnect the node, and run the graph again, the error goes away. The error only shows up the first time I run the graph or when I run it from Dynamo Player (which is how everyone else at my company will typically run it).
What am I doing/thinking wrong? I’m sure there are other ways to do what I’m trying to do in this specific case, but this similar situation keeps occurring on other code blocks so I’m hoping there is a generalized solution.