Compare two parameter values to set a third

Hello everyone! First off, thanks so much for all of the knowledge being shared here. It has helped me tremendously as I navigate my way through the Dynamo forest!

I’ve managed to do things like copy parameter values from one to another successfully, but this time I’m stumped as I think I may be dealing with If sorts of statements here. I have no experience or knowledge with coding so I’m hoping to learn enough to figure this out.

My goal is to take two parameters, compare them to each other some way, and then use the result to set a third parameter value. I’ve managed to pull the parameters I want to compare and identify the parameters I want to modify, but when I get to the If part, (using a codeblock) I hit a wall:

My first test is to compare the “Estimated Design Start” parameter to the “Report End” parameter. If the first is greater than the second, then “Future Project” should be ‘Yes’ or ‘1’. If the first is less than the second, then “Future Project” should be ‘No’ or ‘0’. Any direction is very much appreciated!

You’re almost there. You need to use the parameter values instead of the parameter names and then define your outputs for True and False, 1 and 0.

Thanks for the quick response! So rather than saying “Estimated Design Start” in the string, I should pull the value from the “Element.GetParameterValueByName” node? I then set my “True” result as “1” and my “False” result as “0”?

Would I then use something like the “Parameter.SetValue” node to turn my “Future Projects” parameter on or off, (set to 1 or 0)?

Exactly. The IF node will give you the output based on your condition, then you can use that value as the input when you set the parameter values.

1 Like

Okay, I think I get the idea, however it looks like I may have missed a step. For my “If” statement node, I set the test to be x, (‘Estimated Design Start’ pulled with the Element.GetParameterValueByName node) is greater than y, (‘Report End Date’ also pulled with the Element.GetParameterValueByName node). I then set the True value to be “1” with a string node and False value to be “0” with a string node. Initially I connected the result of that to a Parameter.SetValue node for my ‘Future Project’ parameter. I got a warning that it couldn’t use a string for the value. When I then attached a Watch node to see what I was getting, I didn’t get a list of 0’s and 1’s as I had expected.

Here’s the updated script:

Any additional feedback would be very appreciated!

Your Future Project parameter isn’t a string parameter. Make sure your input matches the parameter type.