# Modelical | ColorByParameter | Python code edit help needed

**URL:** <https://forum.dynamobim.com/t/modelical-colorbyparameter-python-code-edit-help-needed/47966>\
**Category:** Revit\
**Tags:** python\
**Created:** [March 11, 2020, 3:00pm UTC](https://forum.dynamobim.com/t/modelical-colorbyparameter-python-code-edit-help-needed/47966 "2020-03-11T15:00:19Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![bvs1982](https://avatars.discourse-cdn.com/v4/letter/b/43a26b/32.png) [@bvs1982](https://forum.dynamobim.com/u/bvs1982)\
**Post date:** [March 11, 2020, 3:00pm UTC](https://forum.dynamobim.com/t/modelical-colorbyparameter-python-code-edit-help-needed/47966/1 "2020-03-11T15:00:19Z")

</div>

Hello community, @FrantxoMOD ,

I found this Graph ([https://www.modelical.com/en/node/color-by-parameter/](https://www.modelical.com/en/node/color-by-parameter/)) which is really useful for my project, except for one thing… I want the colors to change in ALL (even better would be selected) Views.  
Can the Python code in the Modelical be changed in such way the color will be overriden in ALL (or or even better selected) Views? I know Dynamo, but i can’t write Python.

 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/1/31564cb32455ea057eafacdc448a3635cb3b4f3b.png)

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [March 11, 2020, 3:01pm UTC](https://forum.dynamobim.com/t/modelical-colorbyparameter-python-code-edit-help-needed/47966/2 "2020-03-11T15:01:58Z")

</div>

I’m guessing the code applies to the active view. You would just need to wrap that portion in a loop for a list of views.

---

<div class="post-metadata">

**Author:** ![bvs1982](https://avatars.discourse-cdn.com/v4/letter/b/43a26b/32.png) [@bvs1982](https://forum.dynamobim.com/u/bvs1982)\
**Post date:** [March 11, 2020, 3:07pm UTC](https://forum.dynamobim.com/t/modelical-colorbyparameter-python-code-edit-help-needed/47966/3 "2020-03-11T15:07:05Z")

</div>

> [@Nick\_Boyts](#):
>
> You would just need to wrap that portion in a loop for a list of views.

If i only knew how to do that 🙃

Learning Python is on my to-do list. I am learning Dynamo on the job / during projects and i am getting better at it (made some really nice .dyn). But also learning Python at the same time is a bit much at the moment.

---

<div class="post-metadata">

**Author:** ![bvs1982](https://avatars.discourse-cdn.com/v4/letter/b/43a26b/32.png) [@bvs1982](https://forum.dynamobim.com/u/bvs1982)\
**Post date:** [March 11, 2020, 3:17pm UTC](https://forum.dynamobim.com/t/modelical-colorbyparameter-python-code-edit-help-needed/47966/4 "2020-03-11T15:17:08Z")

</div>

I am looking at this [https://forum.dynamobim.com/t/element-overrideinview-but-for-multiple-views/37072/6](https://forum.dynamobim.com/t/element-overrideinview-but-for-multiple-views/37072/6) topic. To put it differently 😅, i am NOT to lazy to find out myself, but i am a bit under time pressure.

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [March 11, 2020, 3:17pm UTC](https://forum.dynamobim.com/t/modelical-colorbyparameter-python-code-edit-help-needed/47966/5 "2020-03-11T15:17:32Z")

</div>

There are a bunch of posts on here about modifying python to work on a list. It’s worth looking into for sure. Depending on how complex the original code is, adding another loop is generally pretty straight forward.

That being said. I’m not familiar with this node and I can see enough in your image to know how it works. Are you providing a single view or does it automatically use the active view? If you can provide a view you can easily wrap this node in another custom node and feed it a list of views to iterate over. If the code automatically uses the active view you can still change it to an input and do the same thing.

---

<div class="post-metadata">

**Author:** ![bvs1982](https://avatars.discourse-cdn.com/v4/letter/b/43a26b/32.png) [@bvs1982](https://forum.dynamobim.com/u/bvs1982)\
**Post date:** [March 12, 2020, 10:41am UTC](https://forum.dynamobim.com/t/modelical-colorbyparameter-python-code-edit-help-needed/47966/6 "2020-03-12T10:41:51Z")

</div>

I gonna go for a different approach. I will use the Python code provided in this 👇 topic.

> [@Element.OverrideInView but for multiple Views?](https://forum.dynamobim.com/t/element-overrideinview-but-for-multiple-views/37072/9):
>
> The Clockwork node View.OverrideElementTransparency works as expected but only if I set its lacing to longest. I think I can hack it. How to make this Python script by itself lace longest as there is no lacing setting on its node? [image]

Too soon. That script also overrides the lines. I don’t want to override the color of the lines.

EDIT  
Fixed the overrides lines

```
import clr
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import OverrideGraphicSettings, Color
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

elements = UnwrapElement(IN[0])
views = UnwrapElement(IN[1])
fill_pattern = UnwrapElement(IN[2])
color_input = IN[3]
color_l= color_input.split(" ")
color = Color(int(color_l[0]),int(color_l[1]),int(color_l[2]))
TransactionManager.Instance.EnsureInTransaction(doc)
for i in elements:
	for view in views:		
		ogs = OverrideGraphicSettings()		
		ogs.SetProjectionFillColor(color)
		ogs.SetProjectionFillPatternId(fill_pattern.Id)
		ogs.SetCutFillPatternId(fill_pattern.Id)
		ogs.SetCutFillColor(color)
		ogs.SetHalftone(False)
		ogs.SetSurfaceTransparency(IN[4])
		view.SetElementOverrides(i.Id, ogs)	
TransactionManager.Instance.TransactionTaskDone()

```

---

<div class="post-metadata">

**Author:** ![Alban\_de\_Chasteigner](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alban_de_chasteigner/32/39650_2.png) [@Alban\_de\_Chasteigner](https://forum.dynamobim.com/u/Alban_de_Chasteigner)\
**Post date:** [March 12, 2020, 11:23am UTC](https://forum.dynamobim.com/t/modelical-colorbyparameter-python-code-edit-help-needed/47966/7 "2020-03-12T11:23:47Z")

</div>

Hi,

You could use the _Override Graphics in View_ node with a list of elements, a list of views and a list of colors. (All inputs are optional)

 ![Override Graphics in View](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/8/0807b47a395605e8cb3b56a390cb083192fd5952.png)

---

<div class="post-metadata">

**Author:** ![bvs1982](https://avatars.discourse-cdn.com/v4/letter/b/43a26b/32.png) [@bvs1982](https://forum.dynamobim.com/u/bvs1982)\
**Post date:** [March 12, 2020, 11:33am UTC](https://forum.dynamobim.com/t/modelical-colorbyparameter-python-code-edit-help-needed/47966/8 "2020-03-12T11:33:29Z")

</div>

@Alban_de_Chasteigner

Thanks for your reply. I am using your package build 2020.1.16, but i can’t find this node.  
I guess it is available in a later version?

---

<div class="post-metadata">

**Author:** ![Alban\_de\_Chasteigner](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alban_de_chasteigner/32/39650_2.png) [@Alban\_de\_Chasteigner](https://forum.dynamobim.com/u/Alban_de_Chasteigner)\
**Post date:** [March 12, 2020, 11:35am UTC](https://forum.dynamobim.com/t/modelical-colorbyparameter-python-code-edit-help-needed/47966/9 "2020-03-12T11:35:23Z")

</div>

Yes the custom node was made in February.

---

<div class="post-metadata">

**Author:** ![truevis](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/truevis/32/8634_2.png) [@truevis](https://forum.dynamobim.com/u/truevis)\
**Post date:** [August 28, 2023, 9:25pm UTC](https://forum.dynamobim.com/t/modelical-colorbyparameter-python-code-edit-help-needed/47966/10 "2023-08-28T21:25:43Z")

</div>

> [@Alban\_de\_Chasteigner](#):
>
> You could use the _Override Graphics in View_ node with a list of elements, a list of views and a list of colors. (All inputs are optional)

Is there a way to override graphics for **linked elements** in a View?

---

<div class="post-metadata">

**Author:** ![Alban\_de\_Chasteigner](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alban_de_chasteigner/32/39650_2.png) [@Alban\_de\_Chasteigner](https://forum.dynamobim.com/u/Alban_de_Chasteigner)\
**Post date:** [August 29, 2023, 9:17am UTC](https://forum.dynamobim.com/t/modelical-colorbyparameter-python-code-edit-help-needed/47966/11 "2023-08-29T09:17:56Z")

</div>

Not for the moment. Not avalaible in the Revit API.

---

<div class="post-metadata">

**Author:** ![Marcel\_Rijsmus](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/marcel_rijsmus/32/8539_2.png) [@Marcel\_Rijsmus](https://forum.dynamobim.com/u/Marcel_Rijsmus)\
**Post date:** [August 29, 2023, 9:28am UTC](https://forum.dynamobim.com/t/modelical-colorbyparameter-python-code-edit-help-needed/47966/12 "2023-08-29T09:28:35Z")

</div>

Depends  
If the parameter in the link is a shared parameter  
You can add the shared parameter to the host file, as a shared project parameter set to the appropriate category  
Then use the override
