Compare parameter value in multiple elements and choose closest value from another list to fill-in another parameter

Hello, I’m new on dynamo so please excuse me if I’m asking a dumb question. My issue is as follows:

I’m trying to implement some electrical calculations for my MEP models in Dynamo, but I’m struggling with the code block nodes.

I want to do this: select all electrical circuit elements and for each one, read a parameter value (Apparent Current) and compare it with a table (right now on excel, but I’d like to move into Dynamo if I can), choose the closest value from that table for each circuit and then put that value on another parameter (B).

Is this only possible with code blocks? or is there another way with nodes? Could anyone shed some light on the syntax to create this “lookup tables” inside dynamo?

Thank you.

@eurzaiz87 Are you able to upload your Excel file and post a few screenshots?

Maybe there is a easier way with python.
but you can do a geometrical approach.

Of course, here’s what I’ve got so far (including an error):


Right now I’m (surprisingly) stuck in what I think should be the easiest part, which is a way to choose which table lookup should dynamo use, depending on a condition for the parameter value.
Any help would be really appreciated!

Your approach seems more straightforward, I’ll give it a shot to see if it works for me, but at least from what I see, it surely does, thank you!

Also, once I fix this with your help, how can I place each result in another parameter? I mean, the final results after the code block, are two independent lists, how can I tell dynamo to apply the parameter value on the right electrical circuit?

Thank you!

Here’s another update:

I’ve managed to apply the conditions and get two lists, but now I need to combine them again and then fill in the results into the final parameter:

This is the last part of the script, any help?

You’ll have to keep your list together in order to keep the list structures the same.

My question is why have two functions (with a similar range) but then split them up depending on values? Why not just use the minimum values for anything less than 100 and the maximum for anything greater than?

Hi Nick_Boyts! Thank you, I’m gonna try your solution!

About your question, I’m not sure if I understand but I’ll try to explain myself:

I split them up because, based on the standard for electrical calculations on my country, I need to use the values from two different tables; depending on the Apparent Current being <100A or >100A.

I could probably use a single code block to lookup both tables, but I’m new on dynamo and I’m still learning the syntax so I’m kind of limited on that. It’s just some rule I have to follow in my country for electrical projects. Eitherway, your solution seems to fix it, so I’ll try it first and optimize later.

I’m guessing you should be using different values for the lookup then? Right now you check to see if the apparent current is greater than 100A but the table for “>100A” then only has values up to 70A?
Something just seems off. Your lookup tables have redundant values (within the individual tables, not between the two of them) and the range doesn’t seem right.

You almost got it! You just need to filter the elements too.
Then you can use element set parameter.

ps:next time please use reply or mention. This way people can reply you faster :slight_smile:


Oh, you’re absolutely right! Something was off: The script should check if the circuit has more or less than 100A (“Apparent Current” parameter) to choose one of two lookup tables, but THEN, compare another parameter called “Ambient Temperature” with the values on the selected table and finally; apply the results into the “Temperature Factor” parameter.

I completely forgot to fix that while I was struggling with the rest of the script, thank you!


I think I get it, it creates two filtered lists and then applies the corresponding values to each element, right? I’m not going to use it on this script because I think it’s working the way it is now (posting picture below), but, I’ll use it on the next script, on which I’m already working :stuck_out_tongue:

(Also, I’m sorry but I don’t know how to use the “mention” feature you mentioned, so, I used “Blockquote”)

Anyway, I’d like to thank everybody for the help, you really saved me!

Here’s what it looks like (I hope it’s alright now):

1 Like

it look perfect. great job! :smiley:

Mention typing @eurzaiz87 - so @ then start typing the person’s name. :slight_smile:

Thank you @yamanyildirim! Now I’m gonna try the next script.
Thank you @JacobSmall, I learn something new here everyday!