Override element in a specified view

Hello everybody, hope you are all fine.
I’ve seen a node called Element.OverrideInView in wich you can override elements in the Active view
i need a node to override elements in a specified view. It is nearly equal to the mentioned node, the only difference is that it takes a view as an input.

Thanks in advance for your help!

PS: I’ve alson seen the node View.SetCategoryOverrides, wich overrides elements in view of a specified category… unfortunately it won’t do the work for my current Graph

Hi :slight_smile:

Not an expert, but if there is a node that allows you to switch from the active view to antoher (making the latter the active view), you could simply use the Element.overrideInView node :slight_smile:

But maybe there isn’t such a node…

You could play around with this python script and instead of the “doc.ActiveView.” part you could feed it the views in which you want to override the settings.
Furthermore you can edit other properties (not only line color) by looking at this:

Thanks for your help @GregX but i don’t understand anything of the Revit API… That seems unearthly to me hehehe

Something like this:

Python script:

import clr

#Import the Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

#Import DocumentManager and TransactionManager
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

#Reference the active Document and application
doc = DocumentManager.Instance.CurrentDBDocument
#Start scripting here:

elems = [UnwrapElement(i) for i in IN[0]]
views = [UnwrapElement(i) for i in IN[1]]
rgb = IN[2]

output = []

#Get the solid fillpattern:
fpe = FilteredElementCollector(doc).OfClass(FillPatternElement)

solidPatternId = 0

for i in fpe:
	pattern = i.GetFillPattern()
	if pattern.IsSolidFill == True:
		solidPatternId = i.Id

#Create the color
color = Autodesk.Revit.DB.Color(rgb[0],rgb[1],rgb[2])

#Create the OverridesGraphicsSettings
ogs = OverrideGraphicSettings()
ogs.SetProjectionFillColor(color)
ogs.SetProjectionFillPatternId(solidPatternId)
ogs.SetProjectionFillPatternVisible(True)

#Transaction start:
TransactionManager.Instance.EnsureInTransaction(doc)

for i in views:
	for j in elems:
		output.append(i.SetElementOverrides(j.Id, ogs))	

#Transaction end:
TransactionManager.Instance.TransactionTaskDone()

#Assign your output to the OUT variable.
OUT = 0

OverrideGraphicsInViews.dyn (7.8 KB)

8 Likes

Many thanks @Martin_Spence! I tried exactly your solution but does not seam to work on Revit 2020.2 and Dynamo 2.3.
Attached you a screenshot of the nodes and the error.

8
Thanks

Hi @jaialcan,

Yeah this was from before we got forground/background control. I cant check this right now, but Im guessing you could make it work by changing the line

ogs.SetProjectionFillColor(color)

To

ogs.SetSurfaceForegroundPatternColor(color)

Cant tell you for sure if you’ll run into trouble further down the line, since Im on a Phone atm. Otherwise i might be able to look into it later.

1 Like

Thanks @MartinSpence for your fast response. I made the change but it looks there is another error. Attached you the screenshot.
9

Yes I can see the methods have been changed to accomodate the functionality. Ill have to look into it later, unless some one beats me to it :slightly_smiling_face:

1 Like

Many thanks @MartinSpence ! I finally got it working with the Genius Locci package. Attached the screenshot as it may be of help to others.