/

/

17-shared-param-importer

/

/

17-shared-param-importer

Day

17

pyRevit

Challenge

Day

17

pyRevit

Challenge

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

21-Day pyRevit Challenge

Mon

Tue

Wed

Thr

Fri

Sat

Sun

Tool Of The Day:

"Shared-Param. Smuggler"

Revit is nothing without shared parameters. But it has quite a few unnecessary steps to understand and automate. So let's dive into that .

Today We're Practicing:

>>>

Check Loaded Parameter ⭐

>>>

Read SharedParameterFile⭐

>>>

Load New Shared Parameters⭐

Let's Create

"Shared-Param. Smuggler"

Using 7-Step PROCESS

Let's Create

"Shared-Param. Smuggler"

Using 7-Step PROCESS

.

.

.

.

.

.

.

PLAN

🫳Revit Is Nothing Without Shared Parameters

I'm sure you already tried running your custom tools and fail because not all projects have your Shared parameters by default…

Or maybe you started a brand new project and it misses too many shared parameters… And importing them manually is such a waste of time.

So, the Goal for Today:

Create a tool that can batch import shared parameters.

We'll ask user what shared paramters to load, then a few additional settings like:

  • Instance or Type

  • Categories

  • Parameter Group

  • Varies by Group

And with that we can import all of them at once saving a lot of time and nerves to our users.

So let's begin Smuggling Shared Parameters.

.

.

.

.

.

.

.

RESEARCH

Coding CheatSheet

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

Coding Blocks

Read Loaded Parameters

Set SharedParameterFile

Find SharedParamtere in File

Get All Categories

Ask User For Categories

Workaround: Set VariesByGroup

Access SharedParameterFile

Read SharedParameterFile

Get Category

Create Category Set

Add Shared Parameter (Instance)

Select Parameter Group

Read Loaded Parameters

Access SharedParameterFile

Set SharedParameterFile

Read SharedParameterFile

Find SharedParamtere in File

Get Category

Get All Categories

Create Category Set

Ask User For Categories

Add Shared Parameter (Instance)

Workaround: Set VariesByGroup

Select Parameter Group

Notes
Revit API Docs
pyRevit Dev Docs
EF-Notes:

🔸Shared Parameter File

Sometimes Revit app doesn't have open SharedParameterFile. If that happens either notify user to set it manually, or you can hardcode your office standard one.

🔸Override SharedParameters

Note that you can't import parameters already in the project. It won't update their settings, so instead you'll need to get definitions and modify it differently. Refer to docs.

🔸Forward Iterator of BindingsMap

If you want to read loaded parameters then you need ParameterBindings map. And you can't read it like a normal list, instead you have to get ForwardIterator where you have to get one item at the time inside while loop to read it. Don't over complicate it. Just copy my code and use it as it is…

🔸API Change for BindingMap Insert

There's minor change in how to select Parameter Group when inserting new Shared Parameters. Nothing complicated, just need to remember to use different code before and after Revit 2024.

.

.

.

.

.

.

.

RESEARCH

Coding CheatSheet

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

Coding Blocks

Read Loaded Parameters

Access SharedParameterFile

Set SharedParameterFile

Read SharedParameterFile

Find SharedParamtere in File

Get Category

Get All Categories

Create Category Set

Ask User For Categories

Add Shared Parameter (Instance)

Workaround: Set VariesByGroup

Select Parameter Group

Notes
Revit API Docs
pyRevit Dev Docs
EF-Notes:

🔸Shared Parameter File

Sometimes Revit app doesn't have open SharedParameterFile. If that happens either notify user to set it manually, or you can hardcode your office standard one.

🔸Override SharedParameters

Note that you can't import parameters already in the project. It won't update their settings, so instead you'll need to get definitions and modify it differently. Refer to docs.

🔸Forward Iterator of BindingsMap

If you want to read loaded parameters then you need ParameterBindings map. And you can't read it like a normal list, instead you have to get ForwardIterator where you have to get one item at the time inside while loop to read it. Don't over complicate it. Just copy my code and use it as it is…

🔸API Change for BindingMap Insert

There's minor change in how to select Parameter Group when inserting new Shared Parameters. Nothing complicated, just need to remember to use different code before and after Revit 2024.

.

.

.

.

.

.

.

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

Read Shared
Parameter File

card-background

5

Import
Shared Parameters

card-background

2

Check Loaded
Parameters

card-background

3

Ask User To Select
Param To Import

card-background

4

Ask Settings: Type/Instance
Categories / Param.Group

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

Read Shared
Parameter File

card-background

5

Import
Shared Parameters

card-background

2

Check Loaded
Parameters

card-background

3

Ask User To Select
Param To Import

card-background

4

Ask Settings: Type/Instance
Categories / Param.Group

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