Updating a parameter value of a Revit element using If node in Dynamo

Hello friends

I modeled a building with all its architectural elements such as its furniture. I assigned some parameters with some predefined values to each of these elements. For example, I assigned the life safety factor to them. The life safety factor values are 1 or 5. I am going to change the life safety factor of the revit elements based on the differences between their coordinates. For example, as shown in the attached picture, the Life safety factor value of the selected revit element is “1”. Using “If” node, I want to change this value to “5” if the “if node result” is True (as shown in attached dynamo file). In fact I want to change the parameter value of the element using “If” node. For example If (x-y)<2000 that is “True”, then change the value of the parameter from “1” to “5”. I attached its dynamo file. It’s really appreciated if you can guide me. Thank u so much in advance.
coloring Architecture New with objects coordinates 3.dyn (12.5 KB)

I don’t fully understand what you are trying to obtain but avoid using the “if” node and instead use “List.FilterByBoolMask”.

Thank you Greg for your response. I defined and assigned a parameter to revit elements. The parameter name is RS(Life Safety). and there are two values for this parameter: 1 and 5. I just want to say, if the difference of Y coordinates of two selected elements is less or equal than 2000 mm, then the value of the parameter becomes 5, otherwise if the difference of Y coordinates of two selected elements is more than 2000 mm, then the value of the parameter becomes 1. I want to make this process dynamic, that when I change the location of those two elements in the Revit model, the value of this parameter changes based on their distance. I attached two photos. One photo from its dynamo environment including the nodes that I used till now, and the other one is from my Revit model which shows an element (Shelving) including its parameters that I spoke about it. I hope these pictures and explanation can help you to help me to solve this problem. Thank you again for your time and cooperation.

I did some of its steps ( I am not sure whether it’s correct or not), but I couldn’t finish it.

Pretty sure this will work for you:

You can change the parameter its writing to and the values etc but it should do what you need :slight_smile:

Thank you so much dear Alisder. I followed your nodes, but in the last nodes, I got errors. I changed the elements location so that their differences in Y direction becomes less than 2000 to change their specified parameter value to 5. But its Run was not completely done. It says that the parameter’s storage type is not a string. I attached its photo. Could you please check whether I put the parameter’s name in the right place and help me to solve this problem? Thank you so much in advance for your time.

if your RS parameter type is a number just remove the “” before and after the 5 in the last code block.

Sorry i should have said. If you look in the last code block, i am writing to the “Comments” parameter, Your parameter (im assuming) will be a number parameter, so you cannot feed in a string. Just remove the “” around the number 5 in the last codeblock as @GregX said and that should do the trick.

Thanks again dear Greg and Alisder

I removed “” between 5. Now There is no error. But the problem is that in any condition the RS parameter is 5. I want that when the difference between the value that is “dist” in the first block is less than 2000, then change the RS parameter value to 5, otherwise when the "dist"is more than 2000, then change the RS parameter value to 1. By using above nodes, the value of RS parameter is 5 in both conditions and is constant.

Copy the nodes that are coming out of the “IN” port on the “FilterByBoolMask” nodes, but connect them up using the “OUT” ports from the “FilterByBoolMask” node.


sorry not on my system, try using a code block with Math.Abs(a-b)<2000?5:1
This node is like an excel if(math.abs(a-b)<2000,5,1). So if the distance is less than 2m it will output 5 otherwise 1, that you will feed in the “Element.SetParameterByName”

Finally It worked. Thank you very very much dear Alisder and Greg for your help and guidance. For the final step, I want to do some graphical task. I know that it may not appropriate for this topic, and maybe you are busy and don’t have time, but since you know my purposes from before, you may understand better than others. Now for each elements I have a parameter namely " Seismic Risk Score" which is a range of numbers. I want to divide this range into 7 categories and assign a color for each category to highlight the elements in Revit model.
For example I want to categorize them into and show them by:
Seismic Risk Score <=16 white
16<Seismic Risk Score<=30 yellow
30<Seismic Risk Score<=50 Brown
50<Seismic Risk Score<=70 Alpha
70<Seismic Risk Score<=100 Blue
100<Seismic Risk Score<=120 Green
120<Seismic Risk Score<140 Red

Could you please help me to do that? Thank you so much in advance

Hopefully this will get you started. You will have to modify it to suit your specific values etc but it is easy enough to modify.
This method overrides graphics in view. You could do a similar method that uses materials (this would take more setting up, creating materials, ensuring all the selected elements have the same material parameter etc.)

Hope this helps :slight_smile:

I think you could also easily do it with a filter in the revit environment without using dynamo (if the parameter is a project/shared one)

Thank you so much

I followed your steps. I defined six color range as shown in the attached picture. I assigned red to the range between 120 to 140 values. But I don’t know why the Curtain panel element with 134 seismic risk score was not shown by red as shown in the figure. I want to represent the elements with seismic risk score between 120 to 140 by red color. Thank you Alisder in advance for your helps.

Thanks GregX. Yes. You’re right. But I was asked to do it by Dynamo. Thanx again

You have not connected the Code block into the override color node

Thanx Alisder. Sorry. I forgot to connect them :blush:

As you know, if you use FamilyInstance.Location, the coordinates of all elements are shown by a point in Dynamo. Each point in Dynamo represents an element in Revit. And each element has a value for seismic risk score (the parameter that I created for all of them). Can I do a process to highlight the points in Dynamo which have seismic risk score for example between 90 and 140? Is it possible? Thank you so much.

Hello interesting topic.
How to return to the original colors.
Thank you.