Wrong Input - how to avoid error in Dynamo Player

Hello Dynamo Community,

I want to set a view template but if it doesnt exist i want to apply another one.
It is working perfectly fine but i always get an error message. I would like to avoid this because i don`t want users to get an error by using this script with dynamo player.

If ViewTemplate 1 does not exist, there is no error.

If ViewTemplate 1 does exist, I get an error because of the “0” at the If node for ViewTemplate 2.

I tried to use another “false input” for the if node. If i use an empty list it is messing everything up.

So is there any way to block the input of a node? Or is there any false-input i can use that won´t give me an error?

Would be really grateful for any help!

Regards

Try using an IF statement and only applying a template once. If Template A exists use Template A, else use Template B.

Hello Nick, thanks for your help!

You mean one template should be the true and the other one the false input? I don´t know why i didnt get it to work or if i tried that. I´m going to try that right now.

I wanted to add that i also tried a runme node instead of the if node, but this node also gives out a “0” and making an error.

Seems like I´m doing it wrong. Maybe i didn´t understand you right Nick?!

Now it works if the Template A exists. But if it does´nt exist the empty list, again, messes up everything. This IF node really does´nt like empty lists on the other input :confused: My true input now won´t get passed…

Correct. The If node won’t work with empty lists. You’ll have to use the code block workaround:

i = test ? 0 : 1;
[trueOutput,falseOutput][i];

Amazing! Had to live with this errors for weeks, but not anymore! :grinning:
Saved my day again Nick, thanks!