
Day
06
Challenge
Day
06
Challenge
Once your Revit model grows big it becomes harder to inspect and verify different aspects.
But once you isolate the right elements it becomes easier to focus on the right things. So today, let's create a tool to Isolate certain elements in 3D Views with a click.
Today We're Practicing:
>>>
Getting Elements
>>>
Simple pyRevit Forms
>>>
Working with Groups✨
>>>
Create 3D Views✨
>>>
Isolating Elements✨
>>>
How to use .NET List[ElementId]✨
P.S. There are quite a lot of new concepts
but most of them a simple and quick to grasp.

Let's Create
"3D Isolation Trap"
Using 7-Step PROCESS
Let's Create
"3D Isolation Trap"
Using 7-Step PROCESS

PLAN
Isolation Trick…
Revit models can grow so big that it becomes really hard to validate model quality.
And sometimes it can be really great to isolate certain elements in 3D views to quickly check.
So, The Goal for Today's Tool:
Create a simple tool to select Group Types and isolate selected groups in a new 3D View.
It can be single view for all types, or new view for each selected type.

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

Coding Blocks
Get GroupTypes

pyrevit form - Select Options

Create 3D View (Isometric)

Turn Python into .NET Typed-List

Get Current Date/Time

Bug: How to read Type Name?

Get Elements from Group

pyrevit form - SelectFromList

Open View in Revit UI

Isolate Elements

Create Linkify Object

Get GroupTypes

Get Elements from Group

pyrevit form - Select Options

pyrevit form - SelectFromList

Create 3D View (Isometric)

Open View in Revit UI

Turn Python into .NET Typed-List

Isolate Elements

Get Current Date/Time

Create Linkify Object

Bug: How to read Type Name?


Revit API Docs
View3D.CreateIsometric Method
View.IsolateElementsTemporary()
Group.GetMemberIds Method
ElementTypeGroup Enumeration
uidoc.ActiveView Property

pyRevit Dev Docs
pyRevit - Effective Inputs
pyRevit - forms.alert Docs
pyRevit - forms.SelectFromList Docs
pyrevit - output.print_md DOcs
pyrevit - output.linkify Docs

Notes
🔸uidoc.ActiveView = View Remark
If you're opening views with Revit API, make sure you use uidoc.ActiveView = view outside of Transaction. Otherwise you'll see an error saying it can't be done during Transaction.
🔸Group != Groupped Elements
When you try to isolate/hide or do something with group, you actually want to do it with grouped elements… Use group.GetMemberIds to get groupped elements.
🔸Type.Name Error
For some reason we can't read type.Name in pyRevit…
I can't explain it, but you can use internal getter [Element.Name.GetValue(elem) ] to solve it.
🔸Today's Error
Just heads up…
I kind of overlooked one simple step during proof-of-concept and we're not getting groups correctly… I noticed during stress-test and fixed it. You'll see real-time debugging which might be more useful than my planned videos. Let me know…

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

Coding Blocks
Get GroupTypes

Get Elements from Group

pyrevit form - Select Options

pyrevit form - SelectFromList

Create 3D View (Isometric)

Open View in Revit UI

Turn Python into .NET Typed-List

Isolate Elements

Get Current Date/Time

Create Linkify Object

Bug: How to read Type Name?


Revit API Docs
View3D.CreateIsometric Method
View.IsolateElementsTemporary()
Group.GetMemberIds Method
ElementTypeGroup Enumeration
uidoc.ActiveView Property

pyRevit Dev Docs
pyRevit - Effective Inputs
pyRevit - forms.alert Docs
pyRevit - forms.SelectFromList Docs
pyrevit - output.print_md DOcs
pyrevit - output.linkify Docs

Notes
🔸uidoc.ActiveView = View Remark
If you're opening views with Revit API, make sure you use uidoc.ActiveView = view outside of Transaction. Otherwise you'll see an error saying it can't be done during Transaction.
🔸Group != Groupped Elements
When you try to isolate/hide or do something with group, you actually want to do it with grouped elements… Use group.GetMemberIds to get groupped elements.
🔸Type.Name Error
For some reason we can't read type.Name in pyRevit…
I can't explain it, but you can use internal getter [Element.Name.GetValue(elem) ] to solve it.
🔸Today's Error
Just heads up…
I kind of overlooked one simple step during proof-of-concept and we're not getting groups correctly… I noticed during stress-test and fixed it. You'll see real-time debugging which might be more useful than my planned videos. Let me know…

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
(Groups)

5.
Isolate
Elements

2
UI Select
Group Type

6.
Interactive
Report

3
UI Select
Single/Multi Views

4
Create new
3D Views

1
Get Elements
(Groups)

3
UI Select
Single/Multi Views

5.
Isolate
Elements

2
UI Select
Group Type

4
Create new
3D Views

6.
Interactive
Report


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

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
Now, it's time to refactor our proof of concept.
Most steps already work well. But users need to set their own naming rules, and it's best to add a custom UI Form.
UI Forms can be a complex topic, but luckily pyRevit has a great option for creating simple forms using rpw.forms.FlexForm.
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
Now, it's time to refactor our proof of concept.
Most steps already work well. But users need to set their own naming rules, and it's best to add a custom UI Form.
UI Forms can be a complex topic, but luckily pyRevit has a great option for creating simple forms using rpw.forms.FlexForm.
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.

Final Code;
So today didn't go as planned…
But it's kind of how it happens in the real world. If you overlook one simple step, it might affect your whole script outcome.
What matters is that we noticed it during Stress-Test section and we solved it right away. But to be honest, we'd catch it earlier if we knew more about the project.
But I hope you enjoyed watching the real raw debugging process with zero preparation
To keep it simpler I'll provide you the full final code below.
Full Final Solution


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


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.

Final Code;
So today didn't go as planned…
But it's kind of how it happens in the real world. If you overlook one simple step, it might affect your whole script outcome.
What matters is that we noticed it during Stress-Test section and we solved it right away. But to be honest, we'd catch it earlier if we knew more about the project.
But I hope you enjoyed watching the real raw debugging process with zero preparation
To keep it simpler I'll provide you the full final code below.
Full Final Solution


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

Time To Celebrate
Share Your Win On LinkedIn
With #pyRevitChallenge
I'll Embed You Here!
Below it's just a placeholder for now…
© 2023-2026 EF Learn Revit API
© 2023-2026 EF Learn Revit API
© 2023-2026 EF Learn Revit API
