Override Element's Color in Multiple Views


#1

Hey guys!

Quick one this time: I am trying to color some elements in multiple views. I was trying to use the ootb node “Element.OverrideColorInView” but then I realized that it just works in the active view! I guess what I’d need is exactly the same node but additional to the “element” and “color” inputs also an input where I say in which views I want to color the elements right?

Is there a way to do that? Is there a package? Or maybe in Python??


#2

Update:

I also tried overriding the graphic settings because I’ve seen they are view-based

Again, it just isolates the elements (as per the last node…see below) but doesn’t color! And the result of “Create Override Graphic Settings” is null :confused: what am I doing wrong?

IMPORTANT: I’m trying to color specific elements that come from a list (from the filter by bool mask) not categories or other.

Cheers!


#3

Not sure how to best accomplish this, but did you consider making selection sets, adding the selection sets to a filter, and applying that filter over multiple views? Would be a lot faster to ‘turn off’ the override after you no longer need it as well.


#4

Hey @JacobSmall

No I actually didn’t think of that…I’m trying it right now: I created a selection set via Clockwork’s SelectionSet.ByElements…now what kind of filter shall I create and how do I add it to a view?

Now I just made it work for a single view in this way

Still not working for multiple views tho…might it be a matter of List@Level?? I tried to input the views list @L1 as I’m doing for the isolate node but without success…but I’m actually still struggling a bit with the levels…

any idea?


#5

So I’m still not getting there and for sure I’m not getting why!!

I’m using the same structure and the same view both in the coloring part and in the isolating part…but what happens is that it correctly isolates the elements but it doesn’t color them, and the result of the element override is 13 (same number of the views) nulls.

I also tried to set the list@level of the Element input of View Set Element Override to @2 but it was kind of getting stuck and calculating for ever…

If anyone sees what am I doing wrong would be great!

Thanks fellas!


#6

This could possibly work:


#7

Hi @Yna_Db !

I actually tried to keep the list structure but still not working…


I really don’t get it! If it works for a single view but not for multiple views it must be a list structure issue no?! I also tried to set the Element input (in View Set Element Override from Hot Gear package) to @2 so I was thinking it was getting the 2 outputs of the Filter but then it starts calculating for several hours (like more than 6/7) so I think there must be something wrong there…

@JacobSmall I’m not able to understand what was your suggestion…can you explain it? Do you mean creating a selection set through SelectionSet.ByElement? And then how do you add selection sets to filters? Would you be able to post an image?


#8

Can’t post a images as I’m not in the office, but yes i was referring to the SelectionSet.ByElement node.

Once you have the selection set, you can use it to create a filter as described here:

After that you can apply the filter to your view as described here:

Dynamo can be used to perform some of these steps, but I recommend using the manual method first so you know more of the ins and outs. I think that the Archilab package by @Konrad_K_Sobon has some nodes to help with that (but again i’m away from the office so i can’t confirm).


#9

Thanks @JacobSmall!

I’m actually familiar with the Revit workflow for the filters (overriding colors for objects for selection sets) but I can’t understand how it should work in Dynamo.

What I was showing above is the same: I’m selecting objects filtering a list based on the values of a parameter, while simultaneously I’m setting the override graphics (see the node View.OverrideGraphicSetting), but it works only for single views and not for multiple ones…


#10

@andreatas. I was actually trying to do a similar thing and found that it is best to use the list level for BOTH view (while keeping the structure) and element AND using cross product lacing. See attached snip.


#11

Can i ask for the .dyn file from the drawing above, still me null


#12

Here’s a solution I came up with when trying to do the same thing:

import clr
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

from System.Collections.Generic import *


doc = DocumentManager.Instance.CurrentDBDocument

def overridecolor(element, color, fillpatternid, view):
	gSettings = OverrideGraphicSettings()
	gSettings.SetProjectionFillColor(color)
	gSettings.SetProjectionFillPatternId(fillpatternid)
	gSettings.SetCutFillColor(color)
	gSettings.SetCutFillPatternId(fillpatternid)
	view.SetElementOverrides(element.Id, gSettings)
	return element

fillpatterns = FilteredElementCollector(doc).OfClass(FillPatternElement).ToElements()
solidfillid = [f.Id for f in fillpatterns if f.Name == 'Solid fill'][0]

if isinstance(IN[0],list):
	color = UnwrapElement(IN[0])
else:
	color = [UnwrapElement(IN[0])]

adskcolor = [Autodesk.Revit.DB.Color(c.Red, c.Green, c.Blue) for c in color]
view = UnwrapElement(IN[1])
elements = UnwrapElement(IN[2])

TransactionManager.Instance.EnsureInTransaction(doc)

for e,c in zip(elements,adskcolor):
	overridecolor(e,c,solidfillid,view)

TransactionManager.Instance.TransactionTaskDone()

OUT = elements

IN[0] = color
IN[1] = view
IN[2] = elements

if you put this inside a custom node you can play with list@level and use it with view lists. I think I’ll create a node and add it to Data-Shapes


#13

I get an error line 41: “Element is not iterable” if I use it with a single element, it works indeed with multiple elements and multiple colors, but if I try on multiple elements and multiple views within a custom node with longest or cross product lacing, it does not work either


#14

Hello @andreatas
I have the same issue and still didn’t find how to resolve it,
I even tried to use the "view set element overrides " from hot gear package to select a view still it didn’t work,
did you find a solution ?
Thank you


#16

this is the workflow


#17

Hi anthony,

I actually ended up changing my workflow, so I didn’t try this one anymore.

Let me know if you find a solution :wink: