/

/

12-click-counter

/

/

12-click-counter

Day

12

pyRevit

Challenge

Day

12

pyRevit

Challenge

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

21-Day pyRevit Challenge

Mon

Tue

Wed

Thr

Fri

Sat

Sun

Tool Of The Day:

"Click Counter"

Ever had to number elements in Revit? Annoying process isn't it?

What if we had a tool that would automate the most annoying and boring part, and just leave you in control of the order for renumbering?

That's what Click Counter will do for you.

Today We're Practicing:

>>>

Infinite Loops✨

>>>

pyRevit Selection

>>>

Parameters

>>>

WarningBar

>>>

rpw FlexForm

Let's Create

"Click Counter"

Using 7-Step PROCESS

Let's Create

"Click Counter"

Using 7-Step PROCESS

.

.

.

.

.

.

.

PLAN

Click. Click. Click. But Better!

Renumbering manually sucks… You need to select an element, click on parameter and fill in the data while remembering the right ordering number. BOOOORING….

So, the Goal for Today:

Create Click Counter tool where we'll be able to set our numbering rules and then click through elements one by one to renumber them.

We can also add control for Renumbering Rules, Category, Parameter name to make it really universal and useful in your daily work.

.

.

.

.

.

.

.

RESEARCH

Coding CheatSheet

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

Coding Blocks

Pick Element (with WarningBar)

Read/Write Shared Parameter

Infinite Loop: Pick Element

RPW Simple Form

Pick Element (with WarningBar)

Infinite Loop: Pick Element

Read/Write Shared Parameter

RPW Simple Form

Revit API Docs
pyRevit Dev Docs
Extra:
Notes

🔸Watch Out For Infinite Loops

Whenever you use while loops double-triple check your exit conditions. Because it's very common to overlook and end up in an infinite loop. And for Revit it means you'll have to kill it to restart and it's annoying…s.

🔸Transaction In/Out Loops?

As a rule of thumb - Transactions should always stay outside of loops for better performance.

However, today we have an exception and we'll put it inside loops. Because we'll be in a loop where users can pick elements one by one and we want to apply results right after the click.

.

.

.

.

.

.

.

RESEARCH

Coding CheatSheet

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

Coding Blocks

Pick Element (with WarningBar)

Infinite Loop: Pick Element

Read/Write Shared Parameter

RPW Simple Form

Revit API Docs
pyRevit Dev Docs
Extra:
Notes

🔸Watch Out For Infinite Loops

Whenever you use while loops double-triple check your exit conditions. Because it's very common to overlook and end up in an infinite loop. And for Revit it means you'll have to kill it to restart and it's annoying…s.

🔸Transaction In/Out Loops?

As a rule of thumb - Transactions should always stay outside of loops for better performance.

However, today we have an exception and we'll put it inside loops. Because we'll be in a loop where users can pick elements one by one and we want to apply results right after the click.

.

.

.

.

.

.

.

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

Set Numbering
Rules

card-background

*

Optionally: Create
UI Form for Rules

card-background

2

Pick One
Element at the time

card-background

3

Calculate
New Value

card-background

4

Write To
Parameter

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

Set Numbering
Rules

card-background

*

Optionally: Create
UI Form for Rules

card-background

2

Pick One
Element at the time

card-background

3

Calculate
New Value

card-background

4

Write To
Parameter

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.

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