Oct 1, 2022
Override Elements with Revit API (SetElementOverrides)
Learn how to override graphics of your elements in a view with Revit API + python. It's actually quite simple, even though we need to use many methods to create settings!
To override graphics with Revit API we need to use .SetElementOverrides(element_id, settings) that is located inside of View Class. It's not a complicated method but it has a lot of methods that you might need to use to create Override Settings that you want to apply to Elements.
First of all we need to create OverrideGraphicsSettings and then we can start modifying it.
There are a lot of different methods for OverrideGraphicsSettings, but yet it's quite simple to use them.
Just think of the menu in Revit UI where you manually have to assign all of the overrides.
You will find methods in Revit API Documentation for each of the controls you have in that UI menu.
👇 Check them out here
How to use OverrideGraphicSettings Methods?
👇 Here is a simple snippet to get everything we need and only change Surface Color of the elements.
Modify to your needs
The snippet above shows you the principle, but it will do just fine to start with. Then go through RevitAPI Documentation and look for methods that you most likely want to use.
I prepared another snippet for you where you can see more examples:
Match Graphic Overrides
This is even easier. To match Graphic Overrides from another element we just need to get OverrideGraphicsSettings and apply it to another element with or without modifying it.