Use Value of Calculated Parameter to Drive Values in a Text Parameter

Hi
I have created a Calculated value to return a range of numbers between 1-6 which represent a Condo Unit based on their areas. Now I want to use those numbers to create text values inside a project parameter (Unit Types).example, where 1 exists in calc.par, then the value in the project parameter is ONE BEDROOM, 2 = ONE BED +, etc. I have nearly 400 units so to match these would be great. I am lost on how to connect them. I have tried understanding Lists a lot more and tried using a lot of those Nodes, but I just cant seem to find it. Match, or Map or something like that. What I am trying is basic, I think!

You’ll want to use a dictionary. You can define each key (calculated value) with a value (unit type) and then return the unit type of all your Rooms based on their value.

Thanks @Nick_Boyts
I had a dictionary in there trying to understand it, but I gave up. I will look at it again.

Think of a dictionary as paired inputs and outputs. You first define the dictionary as keys (inputs) and their respective values (outputs). Once you have the dictionary, you can then take any list of inputs (keys) and have it return the corresponding outputs (values).

I think I have something, but still can’t match them where the values outlined in red is the key that drives the value, but the values outlined in red are not a proper key I don’t think.

You shouldn’t need List.Create between your values and the searchKeys, but that shouldn’t hurt. What output do you get from searching your dictionary? What does the error for setting the parameters say? My first guess is you have mismatched parameter types.

This is where I am at now

The warning is
Warning: Dictionary.ValueAtKey operation failed.
The given key was not present in the dictionary.

So the error basically explains it to you: you are feeding it keys that don’t exist. There is a custom dictionary node from one of the major packages (can’t remember which one unfortunately) that lets you provide a “default” value for keys that don’t exist. You could also filter out the blanks first before getting the values and writing them to the elements. Or you could provide a default value for blank keys in your dictionary from the start. Basically you just need to handle those empty values.

I cleaned the blanks but still have the same error

Ah. Unless you’ve changed it since the last image, you’re creating your dictionary backwards. You have the unit types as the keys and the numbers as the values. They need to be switched.

When I switch them, I get an error.

Warning: Dictionary.ByKeysValues expects argument type(s) (string, var…), but was called with (int, string).

Or should it be switched somewhere else?

The error goes when I change the number 1-6 from Numbers to Strings. but still does not fix the error here

That’s just a combination of two things that I already mentioned. 1) The out of the box node requires keys to be strings. 2) The object type of the keys used to create the dictionary (strings in this case) has to be the same when you’re searching the dictionary. You should just have to convert your list of numbers to strings again before searching the dictionary.

@Nick_Boyts I appreciate the help, and I am not finished with this but as you know, one can get stuck down a Dynamo Rabbit hole and not notice how much time goes by. I had to take a break from it but I will be back at this later in the week.

1 Like