Revit + Python

Revit / Python Resources

R

Creating Python scripts for Revit can, at first, seem like a daunting task.  Just coming up with an idea for a useful tool can be difficult, as you sometimes don’t realize how often you do repetitive tasks until you really stop and assess your workflow.  Are you constantly opening files to make minor changes? Do you find yourself making the same changes on multiple sheets within your project?  

In addition to thinking of tools to streamline repetitive tasks, there are an infinite number of other tools that can be created to enhance Revit’s native capability.  For example, do you want to be able to create a tool that prints all sheets from a Revit index, even if those sheets are in linked files? How about a tool that can open a family and push it into all .rvt files in a directory without having to manually load it into each one?  Both of these are possible (I know, because I’ve done them!).

Once you have an idea for a tool, the real work begins.  The first resource to become familiar with is one that you will return to time and time again….  The Revit API docs.  This site spells out all of the various API commands that can be accessed within Revit, and what arguments each one expects in order to run correctly.  It’s an overwhelming list, but you’ll find that there are only a handful of commands that will be used on a regular basis. We’ll get into those ‘core’ commands in future posts.  There is, however, a fairly large hurdle within the API docs. None of their examples show how to use the command within Python. The closest examples they give are in C#. While somewhat similar to Python, the differences are large enough that some mental gymnastics will be needed to adjust to using it with Python.

Clearly, Google is also going to be one of your best friends in this endeavor as well.  Whether you’re looking for tool ideas or just trying to figure out how to do that one obscure thing within Revit, chances are you’ll find someone that’s tried it.  Unfortunately, most of what I came across still required a lot of interpretation from C# into Python, or required me to go down some other rabbit hole to understand how they were solving the problem.  Hopefully I’ll be able to help with some of the translation and simplification.

Another huge resource is the pyRevit YouTube Channel.  Run by the creator of pyRevit, there are a number of video tutorials on how to begin programming with Python and use pyRevit specifically.  This is a good place to start if you are completely new to both pyRevit and the Python programming language. In addition to the YouTube channel, the pyRevit docs also have great information on how to use pyRevit and the various features it contains.  Of particular importance is the page on forms.  These functions within pyRevit will help streamline your programs and make them as easy as possible for you and your team to use.

As far as general Python training goes, the best online courses I’ve found are on Pluralsight.com.  While the site does cost you, the layout and course content are much more motivating than some of the other online learning sites I’ve tried.  There are also some knowledge quizzes on Python (and Revit, too!) to help assess where your skills are so that you can take the appropriate courses to fill in some gaps.  I was referred to this site after I had taught myself a decent amount of Python, but it was a great resource to learn some basic things I hadn’t touched on before, and to correct some of the incorrect and inefficient things I was programming up to that point.

Finally, the best way to learn, I’ve found, is to just jump in and start coding.  Pick something simple and bang your head against the wall until you finally get it working.  This requires a certain level of patience and persistence, but it will pay off in the end. The satisfaction of getting a tool to work correctly is immense.  Revit is, by no means, a perfect program – being able to bend it to your will is a great way to feel better about using it every day!

What are some good Python resources that I’ve missed?  Are there better learning platforms than Pluralsight? Are there specific Revit Addon resources that are helpful to you?

About the author

Andrew Urban

With almost 15 years as a registered architect, and nearly as much experience using Revit, I have recently taught myself Python and have begun to create productivity increasing addons for Revit. I'm am always interested in learning new and innovative ways to use Revit and all other tools of our profession.

By Andrew Urban
Revit + Python

Andrew Urban

With almost 15 years as a registered architect, and nearly as much experience using Revit, I have recently taught myself Python and have begun to create productivity increasing addons for Revit. I'm am always interested in learning new and innovative ways to use Revit and all other tools of our profession.