Nathan's Revit API Notebook

<<< Return to the Program Lab

About

This page is my personal diary for exploring the API for Revit and Vasari. This page is as much a resource for me as I hope it will be for others.

Developing custom tools for Revit using the API can be a complicated endeavor. The program is quite complex and the development process is not nearly as straightforward as developing tools for more 'free geometry' modelers such as Rhino. Please see Jeremy Tammik's article titled BIM versus Free Geometry and Product Training for a more detailed explanation of the 'barriers to entry' in Revit API development.

This notebook attempts to remedy a few 'resource deficiencies' in learning and applying the Revit API in the context of a design workflow…

  • Design-Related Techniques: Most API examples I have found on the web are related to model management. For designers interested in computation and automation, finding good design-related examples can be a frustrating experience. The examples here show how the Revit API can be used as a design tool specifically within family creation environments such as the conceptual mass.
  • Vasari Implementation: Vasari is essentially a stripped down version of Revit with additional conceptual design and analysis capabilities (and it's free!). Vasari also features a version of the Revit API. The examples here will focus on Varsari's capabilities but most will be applicable in the full versions of Revit.
  • RevitPythonShell-Based Examples: Not many examples exist for using the RevitPythonShell Add-In. The tool provides many iterative scripting capabilities similar to those found in other popular modeling tools such as Rhino. This makes the API much more accessible to designers and those in need of some quick automation!

My hope is that this will save designers time in being productive with the Revit API and perhaps contribute to the creation of a more serious 'scripting culture' around Revit and BIM tools in general….

This is still work in progress and I am learning new things every day. I am positive a few of you could teach me a thing or two… If you have any comments or suggestions please let me know! moc.liamg|hcra.rellimn#moc.liamg|hcra.rellimn

Enjoy!

-Nathan Miller


SharpDevelop IDE

SharpDevelop is a free, open source integrated development environment (IDE) and is a great alternative to Microsoft Visual Studio environments. Visual Studio projects are also natively supported by SharpDevelop.

While you don't necessarily need an IDE for RevitPythonShell use, SharpDevelop supports IronPython so it is a great environment for testing IronPython code through RevitPythonShell and then continuing the development process for creating .NET plug-ins.


Dynamo Python

Python is also implemented inside of Dynamo. I have published some paneling and structure classes here: Python Surface Paneling Class


RevitPythonShell

About

RevitPythonShell is a Revit Add-In created by Daren Thomas. The tool allows developers and designers to write Revit API commands using Iron Python. This allows for a much more fluid, iterative workflow akin to scripting environments in other programs.

Zach Kron has a nice blog post discussing the set-up of RevitPythonShell with Vasari.

The RevitPythonShell is now compatible with Vasari 2.5 and Revit 2012. Get the latest versions here...

Basics

Set-Up
Basic Code Structure
RPS-Setup-ICON.jpg
Learn about the basic code set-up for use with RevitPythonShell
Creating Geometry
XYZ and Reference Points
RPS-Points-ICON.jpg
XYZ and point variables are the building blocks for any geometry creation problem.
Planes and Sketch Planes
RPS-Planes-ICON.jpg
Examples for defining sketch planes for using in creating model curves and other geometry.
Model Curve Creation
RPS-Curves-ICON.jpg
Examples of how to create new model curves using two methods.
Form Creation
RPS-Surfaces-ICON.jpg
Examples for describing different types of forms available in the conceptual environment.
Divided Surfaces
RPS-DivideSrf-ICON.jpg
Examples for creating divided surfaces and pattern systems available in the conceptual environment.
Families
Families and Parameters
RPS-Families-ICON.jpg
Examples of placing families and modifying parameters
Adaptive Components
RPS-Adaptive-ICON.jpg
An example for placing an adaptive component

Object Oriented Programming

Set-Up
Object Oriented Programming
RPS-Object-ICON.jpg
Learn about structuring code for Object Oriented Programming with RevitPythonShell
Custom Form Creation Class
RPS-FormClass-ICON.jpg
An example of using Object Oriented Programming to create custom 'form creation' methods within a class.

Interoperability

Text Files
Using External Text Files
RPS-Text-ICON.jpg
Learn about methods for reading and writing external text files such as CSV.
Excel Files
Using Excel Files
RPS-Excel-ICON.jpg
Learn about methods for reading and writing data with Excel files.

Fun Stuff

The Fun Stuff
Randomization
RPS-Random-ICON.jpg
Examples for using randomization to make forms and change parameters.
Parametric Forms
RPS-Parametric-ICON.jpg
Examples of creating parametric surfaces and forms.

Resources

Links

Invaluable links on this subject no particular order….
Site Description
RevitPythonShell Development The Google Code page for RevitPythonShell by Daren Thomas
The Building Coder Jeremy Tammik's Autodesk blog which extensively covers the Revit API and its uses.
RevitNet Don Rudder's blog about the Revit API and the Vasari SDK.
Buildz Zach Kron's blog about advanced uses of Revit and Vasari conceptual modeling.

License

The code and examples on Nathan's Revit API Notebook pages are free software: you can redistribute them and/or modify them under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

http://www.gnu.org/licenses/.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License