How to Conditionally Create a Parameter in Dynamo Only if It Doesn't Exist (Without Using Packages)

Hello Guys,
So I have a script to “check if a parameters exists” and another script to “create parameters”. I want the “create parameters” script to run only if the “check if a parameters exists” script output is false. What node can I use for this?
I can use some nodes from packages but prefer not to, plz help

Just do a search. Lots of info on this subject. Just have to look.

Actually no, there are posts to do similar thing but not creating parameters. Since I’m using “Parameter.CreateProjectParameter” node I can’t change any of the input like they did.
Run a node based on true false - Packages - Dynamo

Pop up in window for sequence in routine - Revit - Dynamo

Transaction.Start and Transaction.End - Revit - Dynamo

How can I determine the excution order of nodes? - Revit - Dynamo

Conditional execute - Revit - Dynamo

Run/Execute the whole script if it is true or else run/execute the other script - Revit - Dynamo

Why no packages?

What have you tried so far?

To say ‘no packages’ while not showing what you have tried makes this come off as ‘write the code for me’ which is not likely to get many good responses.

You can always use the API and LookupParameter to see if a parameter exists if there are no nodes to your liking. Roll your own node. Not the best tool in the toolbox, but it LookupParameter is quick and dirty.

If you already have a script to see if it exists and one to create one then all you need is an ‘if’ between the two.

If it exists, do nothing.
If it doesn’t exist, create it.

1 Like

That what I did initially but with ‘scopeif’. What will be the input when true at the ‘scopeif’ node.
The script works fine but was just wondering if there is a way I can remove that warning in creating parameters node.

Function passing suppresses all warnings. Pass the scope of as the arg input and remove the name input from the Parameter.CreateProjectParameter node and finally wire the Parameter.CreateProjectParameter node into the function input of the Function Apply node.

Keep in mind this suppressed all warnings, so if there was something else you wanted to know about (if for some reason the parameter could not be created) you won’t know, so you will need to write your own error handling.

1 Like