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
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
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:
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
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.
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.