Method to choose which Function to run or not running a Function at all

I don’t know whether someone else already came up with this method, it seems like someone should have (as I’m not the smarterst person on this forum) but I couldn’t find another topic discussing this and I have seen quite a number of people to who this might be a lot of help.

Consider this situation, you want to run something, but not always, there might be situations where you do not want to write data to Revit or excel, or simply where you might not to want to run a Python script or something complex in a custom node for the simple reason that it takes a whole lot of time to calculate.

Anyway: this is what I came up with:

What we have here is a graph in which you can decide which function to run and decide so via an integer. Setting the slider to 0 will write the data to excel, to 1 will calculate the Average, setting it to 2 will calculate the Sum and 3 will send through the data. I guess it speaks for itself.

I’m thinking the biggest advantage is the ability to easily avoid writing data while still having the ability to do so.

I would create a custom node out of this but I don’t know how to give one a versatile number of inputs.

Side note: I have not tested this with Python scripts as I just don’t know how to write a decent Python script. Also: if someone else came up with a similar method earlier, please link me towards it.


Hi Paul

I like the thought, to “suppress” certain parts of a graph and thus allowing for faster computing without having to connect / reconnect various inputs/outputs, I’m curious though, are you sure that the inputs not chosen with the integer slider are in fact not executed, this should be quite easy to test whether data is written to excel when the option is not chose.

Kudos, I’ll try this out on some of my rather heavy workflows (with an iteration time of 5+ minutes, running for more than 40 minutes (as I’m performing automatic modelling in Robot))

I’ve up till now been using the “scope-if” node in connection with custom nodes for successfully suppressing parts of my graph. :slight_smile:

Using any Type of If node or picking one by Index is practically the same, the latter simply has more options (I made a version with a (regular) If node myself first). I don’t really see why you’d ever want to use more than two different functions, and one of them simply making sure it doesn’t run.

I guess it occasionally might be an option to have a multi-functional graph with which you can choose what to calculate.

But you do prove my thought that people were at least using a similar way to suppress parts of their graph :wink:. Having recently used a List.Map on Excel.WriteToFilenodes I realized that this should be very possible, and it is. I though it should be able to help some people.

My point about “ScopeIF” being different from any other “if” node I’ve encountered is that it does not run the value not passed by the “test” the option to use a standard “if” node or any variance of this was to my knowledge resulting in actually executing both options but only passing the input defined by the “test”.

I think this is why people often see Dynamo crashing if multiple scope-if nodes are used in a single document (as they might collide).

But I’m very open to trying new and better ways and this might indeed by one! I’ll give it a go with a simple Python script as well when I’m at it, this might also open up for even more complex graphs as you could execute multiple different “analysis” or changes to a building by having the user simply choose a number or a string in the player.

Well, I don’t really see it happening you’d be running several lits of different lengths of Functions that you’d want to run over one input.
That does make me think that a List.Create might be a better idea than a List.Join

1 Like