Hey, I’ve a list of concrete elements and steel elements, but i want to run different scripts on them. If my parameter “Element material name” is “Concrete”, i want it to run script A onwards. AND DO NOT RUN SCRIPT B AT ALL! . Similarly, If my parameter “Element material name” is “Steel”, i want it to run script B onwards. AND DO NOT RUN SCRIPT A AT ALL!
I know there are many solutions with if statements saying if input is true, run script, if false, do not run. But its not about true or false, or running script or not. Its about “Concrete” or “Steel” and running Script A or B!
There is no reliable way to prevent part of your graph from running. Dynamo executes everything “all at once”. You do have a few options to work around it though.
Let the unused branch run and fail. You’ll have a warning, but everything will still work.
Wrap the two branches inside a custom node. You’ll still let one branch fail and throw a warning, but the warning will stay inside the custom node and not show anything in the main graph.
Rewrite the two branches in python. Python will let you execute part of the code based on your condition.
You may need to replace the String.Contains operation with something that suits your situation better, but either way, you can use a conditional statement to create 2 lists. The null values will pass through the script and cause warnings, but it will prevent your inputs from going down the wrong branch. You can do a List.Clean operation before each branch if you want to cut down on the warnings (and that might run the script faster).
yeah @SeanP i want to gather info for only one type of element at a time, Like i want to crawl web for “Concrete” only, so I will input concrete in the string, and it will do a separate script to fetch amount of sand, aggregate and cement.
But if i put “Steel”, i do other things for specs, like finding out their weight and rebar number and length etc.
So can’t run the same script for both type of elements.
1- Running and making fail might not work, because im using export to excel in the end of both scripts, with different export options.
2- Please describe the second method, seems reasonable!
3- Yes python is a great option, but I don’t master in python
Writing to Excel is fine. You would just check both outputs before passing that data onto Excel or use a similar condition to get the output of the corresponding material.
Using a custom node is the exact same process as Option 1, you just do it inside the custom node. You just don’t get the warning from running an empty branch.
@Frank_Loftus
Wow, this seems like a solution.
But what if I dont have any element from “Steel”? the B part will go all null and what will happen to the export to excel node in the end of B script? how to stop that to execute?
Although a combined solution may get you where you want to go, but I would suggest looking at different graphs especially since each “branch” is doing completely different things with the elements found. I’d encourage simplicity when possible.
I think you could also use the function apply node on the nodes that output an error, works for me in most cases. Not at a computer now so I can’t try it out for this specific case