How to either use SetParam or SetParamToNone based on value being passed

I want to set a parameter tied to a Key Schedule.

If the value is set to (none), I want to use the SpringNodes SetParameterToNone node to actually set the parameter to none. (I’m assuming this would actually work - haven’t gotten that far.)
If the value is set to anything else, I want to use the typical SetParam.

How do I make that “choice” in the script?

Try an IF statement in a codeblock maybe

Test ? True: False;

xxx == “none”? “none”: whatever you’re feeding in

You could also try an IF node

But either of the Set nodes is going to do its thing BEFORE the If node. I need a way to EITHER do a regular SetParam or SetParamToNone.

Maybe I’m misunderstanding what you’re getting at, but setting the value being fed to those nodes isn’t the problem, it’s how to only let one of those nodes run.

This type of question gets asked all the time. Try some searches through the forum if you need more info, but basically you can’t force Dynamo to run a node conditionally. That node will execute regardless.

What you can do is filter the elements based on the condition and either send them to the SetParam node or the SetParameToNone node that way. The only thing to keep in mind here is that you’ll get a warning if there are no elements meeting one of the conditions. If the node has no elements to manipulate it will likely return a null or empty list. That value is not an issue, but it will still get flagged as a warning for anyone running the graph.

You can also recreate this functionality through the API with Python and then control which methods you use that way.

@Nick_Boyts Yeah, Python is a no-go, I don’t know it well enough.

I’ll try to figure out a way to either not use the SetParamToNone node or to filter the elements fed to it more strictly, which will be complicated in itself.

I’ve seen ScopeIf mentioned before, but I always have issues with it. If it’s present in the script the whole script acts funky. Like Data-Shapes UI boxes popping up over and over and over until I have to End Task on Revit. Delete ScopeIf, the problem goes away. I’m obviously not using it correctly! :smiley:

It’s actually the exact same process regardless of how you handle this. You have to check for a condition. In this case you’re just using a filter to separate the elements that meet those conditions.