/

/

18-3d-cutter

/

/

18-3d-cutter

Day

18

pyRevit

Challenge

Day

18

pyRevit

Challenge

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

21-Day pyRevit Challenge

Mon

Tue

Wed

Thr

Fri

Sat

Sun

🔓CLICK HERE TO UNLOCK BONUS DAYS

Tool Of The Day:

"3D-Cutter"

Today we're going to grab a pair of scissors and cut through 3D floors. This is unique tool, but it will introduce you to working with Geometry in Revit API.

Today We're Practicing:

>>>

Working with Solids & Geometry✨

>>>

Exploring Planes and Normals✨

>>>

Geo. Boolean Operations (Cut)✨

>>>

Bulk Copying Parameters

>>>

Selecting Elements

Let's Create

"3D Cutter"

Using 7-Step PROCESS

Let's Create

"3D Cutter"

Using 7-Step PROCESS

.

.

.

.

.

.

.

PLAN

✂️Cut them in half!

IF you want to split anything beyond the line in Revit - it's a hassle. Find good view, edit boundary, draw new shape, accept, then copy-paste and do the same for second half…

So, the Goal for Today:

Create a 3D Cutter tool that asks the user to pick floors and a detail/model line, then slices each floor in two using a Boolean cut and recreates them as fresh floors with the same type, level, and parameters.

.

.

.

.

.

.

.

RESEARCH

Coding CheatSheet

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

Coding Blocks

WarningBar (with custom color)

Convert Line to plane

Get Solid's Top Face

Cut Solid with Plane (CutWithHalfSpace)

Read Parameter Value (universal)

Capture Original Error Message

Select With WarningBar

Extract 3D Geometry

Mirror Plane

Re-Create New Floor

Delete an Element

Copy All Parameters

WarningBar (with custom color)

Select With WarningBar

Convert Line to plane

Extract 3D Geometry

Get Solid's Top Face

Mirror Plane

Cut Solid with Plane (CutWithHalfSpace)

Re-Create New Floor

Read Parameter Value (universal)

Delete an Element

Capture Original Error Message

Copy All Parameters

Revit API Docs
Other Resources
EF-Notes:

🔸Extracting 3D Geometry

When you extract geometry it will return multiple objects. Always filter for isinstance(geo, Solid) and geo.Volume >0 if you want a real geometry.

🔸CutWithHalfSpace

When cutting geometry you'll use Solid and Plane objects. But keep in mind this will only return you one half of the original shape. To get the second half, you need to create 'mirrored plane' by reversing it's normal. (SO create a new plane based on original one)

Plane.CreateByNormalAndOrigin(-plane.Normal, plane.Origin)

🔸Different Faces

Keep in mind that only PlanarFace has FaceNormal property to determine it's orientation. If your shape has rounded outlines, these bent faces won't have that.

🔸Create Floor in 2021

If you're still work in the past, then you need to use doc.Create.NewFloor(…) instead of Floor.Create method.

.

.

.

.

.

.

.

RESEARCH

Coding CheatSheet

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

Coding Blocks

WarningBar (with custom color)

Select With WarningBar

Convert Line to plane

Extract 3D Geometry

Get Solid's Top Face

Mirror Plane

Cut Solid with Plane (CutWithHalfSpace)

Re-Create New Floor

Read Parameter Value (universal)

Delete an Element

Capture Original Error Message

Copy All Parameters

Revit API Docs
Other Resources
EF-Notes:

🔸Extracting 3D Geometry

When you extract geometry it will return multiple objects. Always filter for isinstance(geo, Solid) and geo.Volume >0 if you want a real geometry.

🔸CutWithHalfSpace

When cutting geometry you'll use Solid and Plane objects. But keep in mind this will only return you one half of the original shape. To get the second half, you need to create 'mirrored plane' by reversing it's normal. (SO create a new plane based on original one)

Plane.CreateByNormalAndOrigin(-plane.Normal, plane.Origin)

🔸Different Faces

Keep in mind that only PlanarFace has FaceNormal property to determine it's orientation. If your shape has rounded outlines, these bent faces won't have that.

🔸Create Floor in 2021

If you're still work in the past, then you need to use doc.Create.NewFloor(…) instead of Floor.Create 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

Pick Floors

to Cut

card-background

5

Get New
Floor Outlines

card-background

2

Pick Model/Detail
Line To Cut With

card-background

6

Create New
Floors

card-background

3

Prepare Cut Geo.
(Solid, Plane)

card-background

7

Copy Parameters
(Original -> New)

card-background

4

Cut Solid
With Plane

card-background

8

Delete Original
Floor

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

Pick Floors

to Cut

card-background

5

Get New
Floor Outlines

card-background

2

Pick Model/Detail
Line To Cut With

card-background

6

Create New
Floors

card-background

3

Prepare Cut Geo.
(Solid, Plane)

card-background

7

Copy Parameters
(Original -> New)

card-background

4

Cut Solid
With Plane

card-background

8

Delete Original
Floor

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