/

/

05-bimpressionist-painter

/

/

05-bimpressionist-painter

Day

05

pyRevit

Challenge

Day

05

pyRevit

Challenge

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

21-Day pyRevit Challenge

Mon

Tue

Wed

Thr

Fri

Sat

Sun

Tool Of The Day:

"BIMpressionist Painter"

Watch Bonus Training:
- Follow pyRevit FastTrack Setup
- Watch P.R.O.C.E.S.S. Masterclass

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✨

>>>

Sorting By Properties/Parameters

>>>

Overriding Element Graphics✨

>>>

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.

.

.

.

.

.

.

.

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
  1. FilteredElementCollector Constructor (in view)

  2. Transaction Constructor

  3. OverrideGraphicSettings Class

  4. Element.CanBeHidden Method

  5. View.AreGraphicsOverridesAllowed Method

  6. View.SetElementOverrides Method

  7. View.GetElementOverrides Method

  8. Color Class

  9. FillPatternElement Class

  10. FillPatternElement.GetFillPattern Method


pyRevit Dev Docs
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

.

.

.

.

.

.

.

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
  1. FilteredElementCollector Constructor (in view)

  2. Transaction Constructor

  3. OverrideGraphicSettings Class

  4. Element.CanBeHidden Method

  5. View.AreGraphicsOverridesAllowed Method

  6. View.SetElementOverrides Method

  7. View.GetElementOverrides Method

  8. Color Class

  9. FillPatternElement Class

  10. FillPatternElement.GetFillPattern Method


pyRevit Dev Docs
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.

1

Get
Elements

card-background

5.

Override
Elements

card-background

2

Sort
Elements

card-background

6.

Legend Report
(Interactive)

card-background

3

Define
Color Library

card-background

4.

Create
GraphicsSettings

card-background

1

Get
Elements

card-background

3

Define
Color Library

card-background

5.

Override
Elements

card-background

2

Sort
Elements

card-background

4.

Create
GraphicsSettings

card-background

6.

Legend Report
(Interactive)

card-background

.

.

.

.

.

.

.

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

card-background

2

Sort
Elements

card-background

3

Define
Color Library

card-background

4.

Create
GraphicsSettings

card-background

5.

Override
Elements

card-background

6.

Legend Report
(Interactive)

card-background

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…

Proof Of Concept

SCRIPT: PROOF OF CONCEPT

.

.

.

.

.

.

.

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

.

.

.

.

.

.

.

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

.

.

.

.

.

.

.

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

.

.

.

.

.

.

.

STRESS-TEST

Time To Break It!

Don't rush sharing your tools.

Try breaking it before your team does it… You don't want to hear how your tools fails at the cost of your reputation.

Test #1 - Check ViewType

Let's ensure that users have correct ViewType open so we can get elements and set graphic overrides correctly.

SOLUTION #1 - Check ViewType

Test #2 - Ensure you get elements

This one is simple, we just need to verify that we got some elements after we sorted them inside of dictionary.

SOLUTION #12

Test #3 - Ensure enough colors

If you decided to pre-define your library of colors, then make sure that you have enough to match all possible options.

There are different ways to fix it, I'll just double the list until there's more than enough elements because I have 50 by default which should be enough.

SOLUTION #3

Test #4 - Check if can be overriden

This one is kind of optional. It's just an extra safety check for very unique situations where you might get elements that can no be modified for some reason…

Also note, there's no direct method to check for overriding graphics, but we can use CanBeHidden since it usually should work the same.

SOLUTION #4

AI - Ask for API Changes

Lastly, let's make sure that we don't have any changes in different Revit versions due to API changes.

AI makes it so easy, that you should always try to run it in the end to double check if you forgot anything or not..

PROMPT:

.

.

.

.

.

.

.

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 Wins On LinkedIn
With #pyRevitChallenge

I'll Embed Them Here!


© 2023-2026 EF Learn Revit API

© 2023-2026 EF Learn Revit API

© 2023-2026 EF Learn Revit API