/

/

15-workset-grabber

/

/

15-workset-grabber

Day

15

pyRevit

Challenge

Day

15

pyRevit

Challenge

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

21-Day pyRevit Challenge

Mon

Tue

Wed

Thr

Fri

Sat

Sun

Tool Of The Day:

"Workset Grabber"

Worksets can be really powerful in Revit.

But to push it a bit further we can create custom tools to help us select workset element to isolate, inspect and make our change to.

So let's make Workset Grabber.

Today We're Practicing:

>>>

Worksharing Elements

>>>

Revit API Selection

>>>

FEC Filters (Slow/Quick/Logical)✨

Let's Create

"Workset Grabber"

Using 7-Step PROCESS

Let's Create

"Workset Grabber"

Using 7-Step PROCESS

.

.

.

.

.

.

.

PLAN

🫳Grab Them By The Workset

Sometimes it might be really helpful to grab your elements by Workset and isolate them in view so it's easier to find and fix something.

So, the Goal for Today:

Create Workset Grabber tool that will provide us a menu to select workset and then select all elements in the project with that workset.

.

.

.

.

.

.

.

RESEARCH

Coding CheatSheet

Here's everything you might need for today's challenge.

Coding Blocks

Get All Worksets

Get Workset Elements (Simple)

Change Selection

pyRevit Form - SelectFromList

Example of ElementWorksetFilter

Extra: Sort Elements by Worksets

Get All Worksets

pyRevit Form - SelectFromList

Get Workset Elements (Simple)

Example of ElementWorksetFilter

Change Selection

Extra: Sort Elements by Worksets

Revit API Docs
pyRevit Dev Docs


In-Depth Filters:

Notes

🔸FilteredElementCollector Filters

FEC has methods like .OfClass/OfCategory… And these are actually shortcuts to apply filters. And there are more filters available if you look into that.

And luckily there's ElementWorksetFilter to get elements of certain workset

🔸Slow vs Quick Filters

First of all, as a beginner you shouldn't care if you use Quick/Slow filters. Just make it work…

But in a nutshell, quick filters need less memory because they only read the main information about elements to filter. Slow filter on the other hand need to expand and read more properties and data about elements to filtr, therefore they are slower.

But in 99% cases the difference is in fraction of a second… That's why you should focus on making it work and not most optimized code.

.

.

.

.

.

.

.

RESEARCH

Coding CheatSheet

Here's everything you might need for today's challenge.

Coding Blocks

Get All Worksets

pyRevit Form - SelectFromList

Get Workset Elements (Simple)

Example of ElementWorksetFilter

Change Selection

Extra: Sort Elements by Worksets

Revit API Docs
pyRevit Dev Docs


In-Depth Filters:

Notes

🔸FilteredElementCollector Filters

FEC has methods like .OfClass/OfCategory… And these are actually shortcuts to apply filters. And there are more filters available if you look into that.

And luckily there's ElementWorksetFilter to get elements of certain workset

🔸Slow vs Quick Filters

First of all, as a beginner you shouldn't care if you use Quick/Slow filters. Just make it work…

But in a nutshell, quick filters need less memory because they only read the main information about elements to filter. Slow filter on the other hand need to expand and read more properties and data about elements to filtr, therefore they are slower.

But in 99% cases the difference is in fraction of a second… That's why you should focus on making it work and not most optimized 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 All
Worksets

card-background

2

Ask User To
Select Workset

card-background

3

Get Workset
Elements

card-background

4

Change Selection
in Revit UI

card-background

P.S. There are not many steps… But defining all workset rules can take quite some time and code. So buckle up.

.

.

.

.

.

.

.

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 All
Worksets

card-background

2

Ask User To
Select Workset

card-background

3

Get Workset
Elements

card-background

4

Change Selection
in Revit UI

card-background

P.S. There are not many steps… But defining all workset rules can take quite some time and code. So buckle up.

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: Single Workset

Refactored: Multiple Worksets

.

.

.

.

.

.

.

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: Single Workset

Refactored: Multiple Worksets

.

.

.

.

.

.

.

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.

https://www.loom.com/share/d9a77a1949f54c95a90ec1778062c575

Final Code

AI Prompt - Stress Test

.

.

.

.

.

.

.

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