Override Graphic Settings in all Views

Hi everyone,

I am trying to create a graph that overrides the color of some revision Clouds.
I would like Dynamo to override the Color in all views that contain the selected Revision Clouds though (as in the dependent views too). I am now stuck in the python script - could someone help me with that? Thanks!

i think you cant check if the element is in view by " if element in view "
try to use OwnerView node to get the desired views from the elements and use it as an input fo views

1 Like

OwnerView doesnt catch the dependents unfortunately…

this can help you

1 Like

Make sure the length of your elements list and view list match. (element that is on view should be paired with the view)

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])
rgbcolor = IN[1]
views = UnwrapElement(IN[2])

ogs = OverrideGraphicSettings()
ogs.SetProjectionLineColor(Color(rgbcolor.Red,rgbcolor.Green,rgbcolor.Blue))

TransactionManager.Instance.EnsureInTransaction(doc)

for i, k in zip(elements,views):
	k.SetElementOverrides(i.Id, ogs)
	
TransactionManager.Instance.TransactionTaskDone()

OUT = "Ok"

Look carefully and you see that in your script you’ve closed the Transaction with TransactionManager.Instance.TransactionTaskDone() but never started in the first place with
TransactionManager.Instance.EnsureInTransaction(doc)

And for the next time, to make it easier to help you, show the Python error.

1 Like

Thanks! How could i make the length of the elements list and the view list match now?
I am using this graph for Revision Clouds, so i will nearly always have more elements than views… Thanks!

Here you go ma’am.

1 Like

So here’s the logic for you:

zip() in Python is one of the basic functions to go trough the multiple list at the same time. So if you have list I with [1,2,3,4,5] and list II with [a,b,c,d,e], then zip(list I, list II) will make the fiction go trough in pairs (1,a), (2,b), (3,c) … etc. So we feed here this:

for i, k in zip(elements,views):
	k.SetElementOverrides(i.Id, ogs)

Which means for each view (here it called k) in views take the view and execute SetElementOverrides with the paired element ID (here it’s i) and OverrideGraphicSettings.

So zip is pairing stuff. This script wouldn’t work if the paired element is not on the view. So what I did is extracted views and with custom node from MEPover, correlated revisions clouds. So the pairs are correct. And python script works.

So if you have multiple revision clouds on single view then the MEPover node wil give you multiple items per view. So to make it work you need to have something like (view1 , rev.clo1), (view1 , rev.clo2) if rev.clo2 is on the same view etc. So basically make correct pairs, then feed it in python as 2 single level lists.

2 Likes

Thank you very much, that was really helpful!
I tried to go a different path and probably overcomplicated everything - but it works as well :slight_smile:

1 Like

Ok, this doesn’t work quite perfectly yet - here a link to a proper working example. I am a beginner, so I probably overcomplicated some things, but it works thanks to @AlexanderBerg and @Kibar

1 Like