Resources
Lesson Objectives
Download pyCharm IDE (Code-Editor)
Learn how to explore, copy and adapt open-source code
Find multiple resources with pyRevit code examples
How to reverse engineer the code with Chat GPT
Possible issues with code
Are you Ready?
Summary
Steal Like an Artist
In the programming world, the phrase "Steal Like an Artist" isn’t about plagiarism—it’s about learning, borrowing ideas, and building upon the knowledge of others.
It’s a mindset that encourages developers to explore existing work, understand how it works, and use it as a base to create something new, improved, or uniquely tailored to their needs.
Probably, you've heard countless jokes about programmers using google better than others and copy-pasting a lot of code. It's certainly true to a certain extend, but copying code is never enough. You need to know how to adapt it to your own needs.
So let me show you where to find countless examples of pyRevit code so you can:
Learn from existing code
Copy parts of the code for your own needs
Or even copy entire tools to impress your boss.
This is a great way to collect a lot of tools that you might need in your work that you can later adapt to your specific workflows. It will give you a taste of being a pyRevit Hacker and you can introduce your team and your boss to pyRevit and prove that it's a viable option worth investing into.
Everybody loves to hearing about magic buttons that you click and work gets done.
Download Code-Editor
Before we start exploring existing code we need to get a code editor like pyCharm or VS Code. We won't configure them for Revit API yet, we do that in another lesson.
For now we want to open python files with colored highlights, so it's easier to read and make changes inside.
Download pyCharm Community (Make sure you Download Free Community version)
💡Tip: Many people encounter issues with the latest versions of pyCharm, so I recommend to reinstall pyCharm with older version in case you encounter any issues.
Once downloaded, install it as usual. During installation, check these options:
Add “Open Folder as Project.”
Add Community Edition to the PATH.
Create file associations for Python files.
Once installed, restart your computer (or do it later if you’re feeling rebellious).
Your First Heist: Steal pyRevit Code
Now the fun begins.
Let’s open Revit and go to the pyRevit tab to check out some tools.
Firslt, keep in mind that you can use [ALT]+[CLICK] to open source folder of any pyRevit tool. This is the best part about pyRevit for hackers. Everything is Open-Source.
You can explore pyRevit extension and choose anything that makes more sense to you. In my case, I will select 'Create parallel Section' tool inside Views pulldown menu (shown above).
Hover over the selected tool and use ALT+CLICK to open its folder.
Inside as a minimum you will find:
script.py
icon.png
There might be additional files like:
bundle.yaml - Used optionally to store meta data about the script (Name, description…)
icon.dark.png - An icon for Dark Theme
Script.xaml - This is a Markup language used for custom UI forms.
At this point, we don't really care as we will copy the whole .pushbutton
folder as it is. So let's do that.
Copy pushbutton folder
Create StealLikeAnArtist.panel or choose any other in your own extension
Paste copied pushbutton folder.
Reload pyRevit and voilà!
💡PS. If you can't see your panel or pushbutton, double check if you have bundle.yaml file that controls sorting and visibility. If yes, then add your new tool or panel to this list.
And now you should have a new tool inside your own custom extension.
Power of Open-Source Code
Keep in mind, the goal is not to steal tools and claim them as your own.
The goal is to see how simple it can be done and provide you a lot of working code examples so you can:
Explore the code
Learn from It
And even reuse for your own needs
That's the power of working with Open-Source code.
Reverse Engineering Basics
Now that you found a tool you might be interested in, we can have a look at the code.
Many of you are still beginners and you might not understand every single line of code, and that's fine. You can still scroll through the code and you will get the general idea of what's happening by reading function and variable names and seeing the logic written out.
If it's still overwhelming you can use Chat GPT to decifer the code and break it down into simpler steps. You can even turn the found code into a written tutorial for beginners thanks to Chat GPT.
For example you can use the following prompt:
I want you to act as a seasoned Python software engineer with extensive expertise in Revit API and pyRevit. I will provide a piece of existing pyRevit code, and I need you to:
Provide a short and clear code overview outlining all the steps.
Write a step-by-step tutorial tailored for a beginner pyRevit user, explaining each section of the code in simple terms.
Describe all Revit API concepts used in the code, offering beginner-friendly examples where necessary.
Here is the code:
{PASTE CODE HERE}"
Experiment with this prompt and try to adjust to your own needs. Also let me know if you find a way to get much better results. I would love to heard about it.
Install more extensions
Alright, you know how to steal default pyRevit tools, but what if I told you that there are even more extension you can have a look at.
You can go to pyRevit -> Extensions Manager and install additional extensions like my EF-Tools extension for example.
This will open up this menu where you can install a lot more extensions provided by other pyRevit Hackers. And everything in this list is 100% Open-Source as well. Isn't it amazing?
I highly recommend you to install different extensions and have a look what kind of tools you can get out of them. And trust me, there are a lot of tools out there!
Steal From Other Extension
Same as pyRevit you can steal tools from other extensions.
Let's steal something from my own EF_Tools extensions. And if it makes you feel any better, I grant you the permission to do anything you want with my code found in EF-Tools. Now you can't feel any guild by taking my code.
For instance, the “Split Regions with Line” tool is great for cutting filled regions in Revit.
To copy this tool:
Locate the tool in the EF-Tools extension folder using the same
Alt + Click
method.Copy the folder and paste it into your extension.
Reload pyRevit, and test the tool.
This tool is now part of your custom toolkit!
You are getting more and more power in your toolbar.
Possible Issues with Copying
Sometimes, copying isn’t straightforward. For example, tools may rely on custom libraries or reusable functions found inside the library folder.
Usually you will encounter ImportError
saying that cannot import using certain module, that's a hint that copied script uses reusable code. And don't worry, this code is still available, it's just located in another place so you need to find and copy it too.
For example, in EF-Tools, reusable functions are stored in the lib
folder in the .extension
root folder. When copying a tool, you may also need to copy its dependencies.
You can either copy the lib folder, or you can find specific functions needed and copy them inside of the script so you don't have to import anything.
Find More Examples
So far I've shown you where you can find hundreds of great tools right inside of the pyRevit extension. But that's not all! Not even close…
We can find thousands more open-source examples on GitHub. And it's very simple. Search for 'pyRevit' to discover repositories with more reusable pyRevit code.
or Click here to open GitHub: pyRevit Search.
You will find 250+ pyRevit extensions on GitHub. Let's say that only 15% of them are good. This will still provide you 37 good pyRevit extensions. Now let's be very conservative and say that you will find ~3 tools that you might be useful to you.
37 x 3 = 111 Tools (And everything is open source🤯).
Plus, don't forget that I'm very conservative with this math example as everyone has their own needs for pyRevit.
Even more resources
I also have a video about Revit API Resources beginners might need on YouTube that you might find interesting after this lesson.
You can watch it here:
pyRevit Hacker's Code Library
Lastly, I want to mention that if you've purchased the full access to this pyRevit Hacker's platform, you will also find a library of my code snippets for pyRevit that I keep updating.
I try to organize all my code snippets to be beginner-friendly and easy to reuse to help you create your awesome tools even faster. The goal is to provide quick and actionable solutions to small problems that you might encounter.
You can find it here if you have access.
Heist is complete!
Alright and that's how to steal like an artist for your own pyRevit extension.
Now I want you to practice before moving to the next lesson. Go out and find a few cool tools that you find interesting and bring them to your own extension.
Remember, the goal isn’t to claim someone else’s work as your own. It’s about learning from open-source tools, improving them, and creating something tailer to you.
Happy Robbing and see you soon.
HomeWork
Alright, grab your robber mask and go for your own heist. Explore available pyRevit extensions and find tools that might be useful for your own workflow and copy them to your own pyRevit Extension.
This will provide you additional practice and you will collect a lot of tools with code that you might reuse or improve later on.
And don't forget to share your findings with the crew. There are so many good tools out there that it's easy to overlook them.
⌨️ Happy Robbing 💰!