/

/

13-floorify-my-rooms

/

/

13-floorify-my-rooms

Day

13

pyRevit

Challenge

Day

13

pyRevit

Challenge

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

21-Day pyRevit Challenge

Mon

Tue

Wed

Thr

Fri

Sat

Sun

Tool Of The Day:

"Floorify My Rooms"

Isn't it annoying creating new floors that should match the boundary of existing rooms? If only we could get its boundary and convert it into floors?

And as you've guessed it, that's exactly what we'll do with today's Floorify tool. And later you'll be able to adjust it for Ceilings, Regions, Lines, Roofs…

Today We're Practicing:

>>>

pyRevit Selection/Forms

>>>

Reading Parameters/Propertis

>>>

Working with Room Boundaries✨

>>>

Creating New Floors✨

>>>

Working With CurveLoops✨

Let's Create

"Floorify My Rooms"

Using 7-Step PROCESS

Let's Create

"Floorify My Rooms"

Using 7-Step PROCESS

.

.

.

.

.

.

.

PLAN

Turn Rooms Into Floors With A Click

I love working on fresh projects because there are so many tasks that can be easily automated.

And crating Finish floor is one of them, because rooms already have the outlines that we need.

So, the Goal for Today:

Create Floorify tool that will ask user to select rooms and it will create floors with the same outline using provided floor type.

.

.

.

.

.

.

.

RESEARCH

Coding CheatSheet

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

Coding Blocks

Pick Rooms

Select FloorType

Room Boundaries -> List[CurveLoop]

Create Floor (RVT 21)

pyRevit output - print_table

Get Default FloorType

Get Room Boundary

Create Floor (RVT 22+)

Set Floor Offset

Pick Rooms

Get Default FloorType

Select FloorType

Get Room Boundary

Room Boundaries -> List[CurveLoop]

Create Floor (RVT 22+)

Create Floor (RVT 21)

Set Floor Offset

pyRevit output - print_table

Revit API Docs
pyRevit Dev Docs
Extra:
Notes

🔸API Changes for Floor.Create (RVT 21/22+)

There's a big difference in how we create floors before and after Revit 2022.

Before we had to use doc.Create.NewFloor that requires CurveArray. And we also had to create Floor and Openings separately with doc.Create.NewOpening…

After 2022, we create a single List[CurveLoop] that can contain boundaries of both main floor and openings.

Since Revit 2021 is so behind already, it's okay to skip it and just limit your tools to Revit 2022+. Unless you're stuck on a project in Revit 2021…

🔸Revit API uses feet internally

If you decide to set Floor Offsets, remember to convert to internal units (feet).

🔸Room Boundary

When you look inside Room Boundaries you'll work with BoundarySegment. But luckily, you can extract the curve eusing GetCurve method.

.

.

.

.

.

.

.

RESEARCH

Coding CheatSheet

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

Coding Blocks

Pick Rooms

Get Default FloorType

Select FloorType

Get Room Boundary

Room Boundaries -> List[CurveLoop]

Create Floor (RVT 22+)

Create Floor (RVT 21)

Set Floor Offset

pyRevit output - print_table

Revit API Docs
pyRevit Dev Docs
Extra:
Notes

🔸API Changes for Floor.Create (RVT 21/22+)

There's a big difference in how we create floors before and after Revit 2022.

Before we had to use doc.Create.NewFloor that requires CurveArray. And we also had to create Floor and Openings separately with doc.Create.NewOpening…

After 2022, we create a single List[CurveLoop] that can contain boundaries of both main floor and openings.

Since Revit 2021 is so behind already, it's okay to skip it and just limit your tools to Revit 2022+. Unless you're stuck on a project in Revit 2021…

🔸Revit API uses feet internally

If you decide to set Floor Offsets, remember to convert to internal units (feet).

🔸Room Boundary

When you look inside Room Boundaries you'll work with BoundarySegment. But luckily, you can extract the curve eusing GetCurve method.

.

.

.

.

.

.

.

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

Ask User To
Pick Room/s

card-background

5

Create Floors
From Rooms

card-background

2

Select
FloorType

card-background

6

Generate
Simple Report

card-background

3

Get Room Boundary

card-background

*

Optionally:
Set Offset

card-background

4

Prepare
List[CurveLoop]

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

Ask User To
Pick Room/s

card-background

5

Create Floors
From Rooms

card-background

2

Select
FloorType

card-background

6

Generate
Simple Report

card-background

3

Get Room Boundary

card-background

*

Optionally:
Set Offset

card-background

4

Prepare
List[CurveLoop]

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