/

/

14-workset-police

/

/

14-workset-police

Day

14

pyRevit

Challenge

Day

14

pyRevit

Challenge

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

21-Day pyRevit Challenge

Mon

Tue

Wed

Thr

Fri

Sat

Sun

Tool Of The Day:

"Workset Police"

Manging worksets can quickly get out of hand without proper workflow and control.

Luckily, Revit API gives you full control. You can define rules on how elements should be sorted into worksets and it happens in seconds.

No more wasting time jumping between worksets.

Today We're Practicing:

>>>

Automating Worksets

>>>

Using Element Collectors

>>>

Working with Parameters

>>>

pyRevit query

Let's Create

"Workset Police"

Using 7-Step PROCESS

Let's Create

"Workset Police"

Using 7-Step PROCESS

.

.

.

.

.

.

.

PLAN

🚨 Whoop Whoop, It's the sound of police🚓👮

Managing worksets manually is really boring and very prone to errors.

Even if you spend whole days fixing your worksets, someone can mess it up tomorrow during next modeling task without you noticing…

So, the Goal for Today:

Create Workset Police tool that can sort your model elements into correct worksets based on your own custom rules. Not only this can save you days, it will also avoid a lot of errors.

.

.

.

.

.

.

.

RESEARCH

Coding CheatSheet

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

Coding Blocks

Get All Worksets

Get Elements By Category

Get Workset By Name

Change Workset

Get All Worksets

Get Workset By Name

Get Elements By Category

Change Workset

Revit API Docs
  1. FilteredWorksetCollector Class

  2. ElementId.IntegerValue Property



pyRevit Dev Docs
Notes

🔸Everyone will have unique rules.

Keep in mind that almost every office has their own workflows and standards and therefore you'll need to adjust your rules to your projects.

🔸This is a good tool to practice OOP Classes

You'll notice that our code is going to grow really big because there are so many categories and rules we can define that it can grow very fast.

Therefor, I'd recommend you to try using classes to better organize your code and keep it more maintainable. (AI can help!)

.

.

.

.

.

.

.

RESEARCH

Coding CheatSheet

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

Coding Blocks

Get All Worksets

Get Workset By Name

Get Elements By Category

Change Workset

Revit API Docs
  1. FilteredWorksetCollector Class

  2. ElementId.IntegerValue Property



pyRevit Dev Docs
Notes

🔸Everyone will have unique rules.

Keep in mind that almost every office has their own workflows and standards and therefore you'll need to adjust your rules to your projects.

🔸This is a good tool to practice OOP Classes

You'll notice that our code is going to grow really big because there are so many categories and rules we can define that it can grow very fast.

Therefor, I'd recommend you to try using classes to better organize your code and keep it more maintainable. (AI can help!)

.

.

.

.

.

.

.

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 Worksets
By Name

card-background

2

Define
Workset Rules

card-background

3

Change Element Worksets

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 Worksets
By Name

card-background

2

Define
Workset Rules

card-background

3

Change Element Worksets

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 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 Will Be Added Later…

.

.

.

.

.

.

.

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