# Assigning colours to elements based on the value of the parameter

**URL:** https://forum.dynamobim.com/t/assigning-colours-to-elements-based-on-the-value-of-the-parameter/53866
**Category:** Revit
**Created:** [August 8, 2020, 10:23pm UTC](https://forum.dynamobim.com/t/assigning-colours-to-elements-based-on-the-value-of-the-parameter/53866 "2020-08-08T22:23:06Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Becky](https://avatars.discourse-cdn.com/v4/letter/b/c4cdca/32.png) [@Becky](https://forum.dynamobim.com/u/Becky)
#### Post date: [August 8, 2020, 10:23pm UTC](https://forum.dynamobim.com/t/assigning-colours-to-elements-based-on-the-value-of-the-parameter/53866/1 "2020-08-08T22:23:06Z")

</div>

Hi,

So I’d like to be able to assign colour to any Revit elements by depending on the value of the parameter assigned to the element. The value of the parameter would be a text type.  
For eg: very high-red colour,  
high-orange colour.  
It’ll be a shared parameter named “Level of Risk”  
Basically, the idea is to be able to visualise the risk level in the model depending on the level of risk assigned to the model element.  
Would appreciate any help on this.

Thank you 🙂

---

<div class="post-metadata">

### Author: ![ingenieroahmad](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ingenieroahmad/32/72992_2.png) [@ingenieroahmad](https://forum.dynamobim.com/u/ingenieroahmad)
#### Post date: [August 9, 2020, 10:44am UTC](https://forum.dynamobim.com/t/assigning-colours-to-elements-based-on-the-value-of-the-parameter/53866/2 "2020-08-09T10:44:54Z")

</div>

you might use the below but you need to filter elements due to the shared parameter you mentioned.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/2/a21db017182698eca585209c6452b6a53d908d49.png)

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/2/52e9b5ec93660b26f9f4f508c16a6e053a32fedf.png)

---

<div class="post-metadata">

### Author: ![AmolShah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/amolshah/32/103244_2.png) [@AmolShah](https://forum.dynamobim.com/u/AmolShah)
#### Post date: [August 9, 2020, 9:54pm UTC](https://forum.dynamobim.com/t/assigning-colours-to-elements-based-on-the-value-of-the-parameter/53866/3 "2020-08-09T21:54:16Z")

</div>

Hi @Becky,  
Welcome to the Dynamo community.  
You can create a dictionary and then use it to find which color needs to be applied to the element based on its Shared Parameter Value.

 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/8/4896b1f5f014362ad632df1d41f9653f311c06f2.png)  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/b/8b7d59e54207cdf8fe4ca88ca6d1a07b8fa468da.png)  
[ColorByDictionaryValue.dyn](https://forum.dynamobim.com/uploads/short-url/9mFMQxjcx7YSdzD1rS8p6C50kiQ.dyn) (13.6 KB)

---

<div class="post-metadata">

### Author: ![Becky](https://avatars.discourse-cdn.com/v4/letter/b/c4cdca/32.png) [@Becky](https://forum.dynamobim.com/u/Becky)
#### Post date: [August 9, 2020, 11:14pm UTC](https://forum.dynamobim.com/t/assigning-colours-to-elements-based-on-the-value-of-the-parameter/53866/4 "2020-08-09T23:14:04Z")

</div>

Hello @ingenieroahmad  
Thanks a lot for taking the time to address my query. I’ll try it out

---

<div class="post-metadata">

### Author: ![Becky](https://avatars.discourse-cdn.com/v4/letter/b/c4cdca/32.png) [@Becky](https://forum.dynamobim.com/u/Becky)
#### Post date: [August 9, 2020, 11:37pm UTC](https://forum.dynamobim.com/t/assigning-colours-to-elements-based-on-the-value-of-the-parameter/53866/5 "2020-08-09T23:37:45Z")

</div>

Hey! @AmolShah  
Thanks a lot. This is so helpful. It sounds silly but the elements can be selected from any view right? Idk why i’m unable to select the elements. If i’m doing something wrong. Apart from this I think it’s gonna work perfectly fine.  
I have another question. To add a step before this current solution, I’d like to create a list of shared parameters to avoid creating and assigning manually, by importing it from excel and from among these is the one parameter i.e., the “Level of Risk” to which I want to assign the colour (Same as the one that’s already one). Would appreciate your input on this as well. 🙂

---

<div class="post-metadata">

### Author: ![AmolShah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/amolshah/32/103244_2.png) [@AmolShah](https://forum.dynamobim.com/u/AmolShah)
#### Post date: [August 10, 2020, 4:03am UTC](https://forum.dynamobim.com/t/assigning-colours-to-elements-based-on-the-value-of-the-parameter/53866/6 "2020-08-10T04:03:57Z")

</div>

Yes, you should be able to select the elements from any view.

The previous solution might not work for Plan Views.  
So in case if you want to use this on a plan view, try this updated graph.

 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/a/0aebddfe47bfd71ccfcf8e2d8e9e6dc75c489608.png)  
[ColorByDictionaryValue.dyn](https://forum.dynamobim.com/uploads/short-url/yo4CaV5rT6dWVxbpozjLqLqggSB.dyn) (23.8 KB)

I didn’t quite follow your question regarding bringing in the values from excel. Can you share a screenshot showing what you want to do?

---

<div class="post-metadata">

### Author: ![Becky](https://avatars.discourse-cdn.com/v4/letter/b/c4cdca/32.png) [@Becky](https://forum.dynamobim.com/u/Becky)
#### Post date: [August 10, 2020, 8:14am UTC](https://forum.dynamobim.com/t/assigning-colours-to-elements-based-on-the-value-of-the-parameter/53866/7 "2020-08-10T08:14:15Z")

</div>

This is what I want to do  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/7/2791d1b1ddf4ab0ed129c58199fdc23cf1c57124.png)

This is how I tried creating the shared parameter, but it’s not getting created.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/7/07fc390859f6a12aff176d620a0bd06109287aca.png) [rough.xlsx](https://forum.dynamobim.com/uploads/short-url/qVTua418T9KN3aQ02spNO88l5Hz.xlsx) (9.1 KB)  
[SafetyParameter.dyn](https://forum.dynamobim.com/uploads/short-url/vVAU05IbxI6ZMpX547AR7GHeM0i.dyn) (19.7 KB)

---

<div class="post-metadata">

### Author: ![AmolShah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/amolshah/32/103244_2.png) [@AmolShah](https://forum.dynamobim.com/u/AmolShah)
#### Post date: [August 10, 2020, 1:34pm UTC](https://forum.dynamobim.com/t/assigning-colours-to-elements-based-on-the-value-of-the-parameter/53866/8 "2020-08-10T13:34:29Z")

</div>

@Becky You were on the right track. Seems like you forgot to provide the categories and mix up inputs for groupName, group and type.

Try this out  
[SafetyParameter.dyn](https://forum.dynamobim.com/uploads/short-url/wEfOOPL7h64Gqao3GPAUlYgfOJf.dyn) (22.3 KB)

 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/0/10f18863c6d917deebcdf59d92c1238e8cf7b7ee.png)  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/c/1ca2ed71d8f742e86c962748b3f4a259ed4d7919.png)  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/c/fc2c9b743733350d4623975be6991f896f0a69ed.png)

---

<div class="post-metadata">

### Author: ![AmolShah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/amolshah/32/103244_2.png) [@AmolShah](https://forum.dynamobim.com/u/AmolShah)
#### Post date: [August 10, 2020, 8:49pm UTC](https://forum.dynamobim.com/t/assigning-colours-to-elements-based-on-the-value-of-the-parameter/53866/9 "2020-08-10T20:49:07Z")

</div>

Btw, a more dynamic approach in my opinion would be to ask Dynamo to create view filters so that you don’t have to run the graph over and over again.  
[RiskLevelFilter.dyn](https://forum.dynamobim.com/uploads/short-url/j1ufyNtrBQFoUEc2Tf0GAbDgEoq.dyn) (58.6 KB)

 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/6/4635b5a8374aba09b1886d816fa0a4a38bc612af.png)  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/3/a30a47ecdd61d9a32a10bc6f6a479f229233d1d0.png)  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/3/232108b1c76d9d56ddcdacf4c0919b4e166a97f0.png)  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/f/ff344defe32b6620cbe9b494cbad86bdf1e4a487.png)

---

<div class="post-metadata">

### Author: ![Becky](https://avatars.discourse-cdn.com/v4/letter/b/c4cdca/32.png) [@Becky](https://forum.dynamobim.com/u/Becky)
#### Post date: [August 13, 2020, 8:22pm UTC](https://forum.dynamobim.com/t/assigning-colours-to-elements-based-on-the-value-of-the-parameter/53866/10 "2020-08-13T20:22:00Z")

</div>

Ah! I hadn’t thought of that. This is a way better approach. Will probably go for this one. Can’t thank you enough for all the help. Thanks a million  
Cheers!
