
Day
05
Challenge
Day
05
Challenge
If you think about it - Revit is like a 3D database containing all our elements with their properties and parameter values.
But it's not the best for visualizing this data. At least, not out of the box… So how about we grab a paint brush and do it Bob Ross Style:
Colorize elements based on their values.
Today We're Practicing:
>>>
Getting Elements In View✨
>>>
Getting Elements In View✨
>>>
Sorting By Properties/Parameters
>>>
Sorting By Properties/Parameters
>>>
Overriding Element Graphics✨
>>>
Overriding Element Graphics✨
>>>
Printing HTML with pyRevit✨
>>>
Printing HTML with pyRevit✨

Let's Create
"BIMpressionist Painter"
Using 7-Step PROCESS
Let's Create
"BIMpressionist Painter"
Using 7-Step PROCESS

PLAN
Ready to Paint?🖌️
Imagine inspecting your Revit models in 3D without schedules or creating tens of view filters…
And yes, it's often best to use View Filters, but there are so many use-cases where it's better to quickly use Graphic Overrides based on certain criteria. Especially when you want to keep your list of view filters clean.
So, The Goal for Today's Tool:
Override element graphics in views based on a certain criteria. We'll start with Walls Category and we'll color based on Type.Name values.
And once it works, you can easily create a lot of useful tools for quick coloring based on your own rules.
So let's scroll down and begin the research.

PLAN
Ready to Paint?🖌️
Imagine inspecting your Revit models in 3D without schedules or creating tens of view filters…
And yes, it's often best to use View Filters, but there are so many use-cases where it's better to quickly use Graphic Overrides based on certain criteria. Especially when you want to keep your list of view filters clean.
So, The Goal for Today's Tool:
Override element graphics in views based on a certain criteria. We'll start with Walls Category and we'll color based on Type.Name values.
And once it works, you can easily create a lot of useful tools for quick coloring based on your own rules.
So let's scroll down and begin the research.

RESEARCH
Coding CheatSheet
Here's everything you might need for today's challenge.

Coding Blocks
Get All Elements (in View)

Color Library (Hardcoded)

Create Override Graphic Settings

Override Element Graphics

Interactive Legend (print_table)

Sort Elements

Color Library (Random)

Get Solid Pattern

print_html color

Get All Elements (in View)

Sort Elements

Color Library (Hardcoded)

Color Library (Random)

Create Override Graphic Settings

Get Solid Pattern

Override Element Graphics

print_html color

Interactive Legend (print_table)


Revit API Docs
FilteredElementCollector Constructor (in view)
Transaction Constructor
OverrideGraphicSettings Class
OverrideGraphicSettings.AllMethods
Element.CanBeHidden Method
View.AreGraphicsOverridesAllowed Method
View.SetElementOverrides Method
View.GetElementOverrides Method
Color Class
FillPatternElement Class
FillPatternElement.GetFillPattern Method

pyRevit Dev Docs
pyRevit Samples: output.print_html
pyRevit Docs: output.print_html
pyRevit Tool: Color Splasher (⚠️Huge Code)

Notes
🔸Why Didn't I Create ViewLegend ?
Honestly, it's best to create a new Legend view to report on colors, but I didn't want to overcomplicate today's tool so we'll just print colors in the console.
🔸GraphicOverrideSettings Confusing?
If settings feel hard - just open Revit UI menu to look at. Right Click -> Override Graphics In View -> By Element.
The settings and the menu is the same thing…
🔸To Reset Overrides…
You can create default OverrideGraphicSettings and apply it to reset all overrides. You can also get overrides from other elements to match it.
🔸Colors Approach
When you need to generate a lot of colors you can begin with random RGB values, but the results won't be great. Instead it's a good idea to create a library of predefined good colors (ask AI…) and then use those RGB values for your needs.

AI Prompt
You can ask AI to help you with the research
but it's NOT 100% perfect solution. Do not rely too much on AI.
AI Research Prompt

AI Prompt
You can ask AI to help you with the research
but it's NOT 100% perfect solution. Do not rely too much on AI.
AI Research Prompt

RESEARCH
Coding CheatSheet
Here's everything you might need for today's challenge.

Coding Blocks
Get All Elements (in View)

Sort Elements

Color Library (Hardcoded)

Color Library (Random)

Create Override Graphic Settings

Get Solid Pattern

Override Element Graphics

print_html color

Interactive Legend (print_table)


Revit API Docs
FilteredElementCollector Constructor (in view)
Transaction Constructor
OverrideGraphicSettings Class
OverrideGraphicSettings.AllMethods
Element.CanBeHidden Method
View.AreGraphicsOverridesAllowed Method
View.SetElementOverrides Method
View.GetElementOverrides Method
Color Class
FillPatternElement Class
FillPatternElement.GetFillPattern Method

pyRevit Dev Docs
pyRevit Samples: output.print_html
pyRevit Docs: output.print_html
pyRevit Tool: Color Splasher (⚠️Huge Code)

Notes
🔸Why Didn't I Create ViewLegend ?
Honestly, it's best to create a new Legend view to report on colors, but I didn't want to overcomplicate today's tool so we'll just print colors in the console.
🔸GraphicOverrideSettings Confusing?
If settings feel hard - just open Revit UI menu to look at. Right Click -> Override Graphics In View -> By Element.
The settings and the menu is the same thing…
🔸To Reset Overrides…
You can create default OverrideGraphicSettings and apply it to reset all overrides. You can also get overrides from other elements to match it.
🔸Colors Approach
When you need to generate a lot of colors you can begin with random RGB values, but the results won't be great. Instead it's a good idea to create a library of predefined good colors (ask AI…) and then use those RGB values for your needs.

AI Prompt
You can ask AI to help you with the research
but it's NOT 100% perfect solution. Do not rely too much on AI.
AI Research Prompt

OUTLINE
Step-by-Step Plan
Break down logic of the tool idea into smaller chunks so it's easier to brainstorm, find hidden steps and code.
OUTLINE
Step-by-Step Plan
Break down logic of the tool idea into smaller chunks so it's easier to brainstorm, find hidden steps and code.
1
Get
Elements

5.
Override
Elements

2
Sort
Elements

6.
Legend Report
(Interactive)

3
Define
Color Library

4.
Create
GraphicsSettings

1
Get
Elements

3
Define
Color Library

5.
Override
Elements

2
Sort
Elements

4.
Create
GraphicsSettings

6.
Legend Report
(Interactive)


NB!
TRY BUILDING
THIS TOOL YOURSELF
DON'T RUSH TO SOLUTION
Unless… You're a Beginner
According to GENERATION EFFECT
The Harder You Work, The Deeper It'll be Wired in Your Brain

NB!
TRY BUILDING
THIS TOOL YOURSELF
DON'T RUSH TO SOLUTION
Unless… You're a Beginner
According to GENERATION EFFECT
The Harder You Work, The Deeper
It'll be Wired in Your Brain

NB!
TRY BUILDING
THIS TOOL YOURSELF
DON'T RUSH TO SOLUTION
Unless… You're a Beginner
According to GENERATION EFFECT
The Harder You Work, The Deeper It'll be Wired in Your Brain

CODE
Code Quick-n-Dirty.
The Goal is to create a proof of concept. Don't try to make it perfect. Skip steps if necessary. Keep it ugly. Keep it slow. JUST. MAKE. IT. WORK…
CODE
Code Quick-n-Dirty.
The Goal is to create a proof of concept. Don't try to make it perfect. Skip steps if necessary. Keep it ugly. Keep it slow. JUST. MAKE. IT. WORK…

Proof Of Concept
SCRIPT: PROOF OF CONCEPT

SCRIPT: PROOF OF CONCEPT


EDIT
Refactor Everything
Once proof-of-concept works - we can focus on all steps to make everything more structured, optimized and easier to read.
EDIT
Refactor Everything
Once proof-of-concept works - we can focus on all steps to make everything more structured, optimized and easier to read.

REFACTOR CODE
REFACTORED CODE

REFACTORED CODE


SHIP
Submit Your Code.
Congratulations! Another tool is complete.
Now let's reflect on what we've learnt and submit your code to keep track of your progress.
SHIP
Submit Your Code.
Congratulations! Another tool is complete.
Now let's reflect on what we've learnt and submit your code to keep track of your progress.
Time To Celebrate
Share Your Win On LinkedIn
With #pyRevitChallenge
I'll EmbedThe Best Posts Here!
PS. My post is just a placeholder for now…
© 2023-2026 EF Learn Revit API
© 2023-2026 EF Learn Revit API
© 2023-2026 EF Learn Revit API

