Python Shell for Revit 2012 and Vasari 2.1

I was so happy to tell you that work on Daren Thomas' RevitPythonShell was recently intensified and endorsed by Zach Kron of buildz to support running in Vasari. Well, the project has been taken a step further: RevitPythonShell now runs in both Revit 2012 and Vasari 2.1.

Zach's post includes simple yet detailed instructions for installing RevitPythonShell in Vasari in 5 minutes, and similar steps also work for Revit 2012.

Here are the modified steps I performed to use it on Revit instead of Vasari:

I actually have IronPython 2.6 installed, not the latest version 2.7. Similarly, I am still running an old version of Python itself, 2.6.2, from Apr 14 2009, no less. Still, all works well, as far as I can tell so far:

RevitPythonShell console in Revit 2012

It shows a simple sample script that demonstrates that I have immediate interactive access to the Revit API functionality. In this trivial case, I just use it to display the document path and read the width of the first wall type in the document WallTypes collection:

>>>from Autodesk.Revit.DB import *
>>>doc = __revit__.ActiveUIDocument.Document
'C:\\Program Files\\Autodesk\\Revit Architecture 2012
>>>iter = doc.WallTypes.ForwardIterator()
>>>wt = iter.Current
<Autodesk.Revit.DB.WallType object at 
0x000000000000002B [Autodesk.Revit.DB.WallType]>

Very many thanks to Daren Thomas, Aki Hogge and Zach Kron for all their effort in creating and improving this powerful tool!

Chatting with Zach, the issue of using this and increasing exposure and access to the Revit API came up. We hope this is going to help bring new coders into the Revit API. Obviously, that is easier if you already know Python. Zach added:

My optimism comes from the big push to Python that is going on in the Rhino community, since they moved from rhinoscripting. They have really wonderful introductory documentation, the Python for Rhino 101 Primer, that actually helped me start to understand how to use the Revit API.

Rhino is the platform of choice in many architecture graduate schools in the US, but I always hear students sigh and say 'I GUESS I should really learn Revit so I can get a job'.

Sections from the primer include:

  1. What is it all about?
  2. Python Essentials
  3. Script anatomy
  4. Operators and functions
  5. Conditional execution
  6. Tuples, Lists and Dictionaries
  7. Classes
  8. Geometry
  9. Notes

You might find this helpful to understand the Revit API and especially the use of the RevitPythonShell as well.

Talking about Rhino and Revit, here is a series of very interesting buildz posts on Revit interoperating with Rhino.