Tag Archives: programming

Revit API – Why to learn programming and where to start?

I have recently started my adventure with Revit API.

Main reason – Revit sucks*.

My main question was:
How much I can improve Revit by learning programming in it?

I’m not an expert yet like Jeremy Tammik but I can answer to this question like this: You can do only as much as developers of Revit API allows you to do. Unfortunately they won’t allow you to change Revit core functionality and introduce new features or objects. (It’s not Sketchup 😉 )

API allows an access to the same commands which are used during normal operation of Revit but still not to all of them. API is improved with every new Revit edition and then new commands are made available.

Learning programming with API can allow you to automate tedious tasks, can allow you to build visual interface to commands (i.e Dynamo is one of them) you can save sequences of these commands as Revit Macros or Add-ins and what most important you can join these commands in thousands of different ways.

Remember:
“Any step that cannot be solved through the user interface can almost certainly not be automated either.”   Jeremy Tammik


So where to start?

I gathered  below the most important links which should answer your questions. Read them. Additionally I will try to help.

First you will need to decide which programming language you should start to learn. It’s not an easy answer. There are 4 of them:

  • C# (sharp)
  • VB.Net
  • Python
  • Ruby

There is plenty of Macros in C# and VB.Net in the Internet.
This is a huge advantage for these languages.  Vast number of commands and a complexity of  relations between them make it nearly impossible to learn programming without examples.

I talked with some IT friends and they advices me to learn Python as the most friendly language still with many resources.
VB.Net is little more friendly then C#.
Ruby is the less popular. I didn’t consider to learn it.

And then came the reality.  I planed to learn Python but when I encountered a problem in my work I could only find a similar Macro in VB.Net. I decided not to translate it to Python (which I didn’t know too well) but only to slightly amend it to my particular problem. This way I end up amending many Macros and learning VB.Net (and a little C#)

Some time passed and the Dynamo which is based on Python got a lot of improvements and become more stable then before. Increase in implementation of API commands made it really functional.
Interface allows to easily build command structures and amend relations between then. Code Blocks of Python code or the whole Nodes can be used regardless of the predefined Dynamo objects.

I would advice everyone now to learn programming in Dynamo using Python but at the same time understanding of C# and VB.Net may be very useful for solving complex problems. At some point it may also be useful to convert code to Add-in and make a desired functionality a permanent element of the Revit user interface.


Additional very useful tools:

  • Revit Lookup  – This tool allows to investigate how Revit is build, check what parameters have objects and what is the relation between them.

How to install Revit Lookup:

Link to download Revit lookup:
  • API help file – RevitAPI.chm – This a library of all the commands available in the current Revit API version along with some examples. If you can’t find a command in there it doesn’t exist.

RevitAPI.chm is a part of  Revit SDK which can be downloaded from the Revit Developer Center.


Additional very useful links:

Jeremy Tammik introduction to  Revit API:
Getting Started

The Building Coder webpage by Jeremy Tammik

Michael Kilkelly introdution to Revit API:

ArchSmarter  webpage by Michael Kilkelly

Boost Your BIM introduction to  Revit API:
Learn to program the Revit API by Boost Your BIM 

Boost Your BIM webpage.

Start with Python:
http://blog.productspec.net/2015/02/03/beginners-guide-to-python-in-autodesk-revit/

PDF about Scripting with RevitPythonShell:
http://thebuildingcoder.typepad.com/files/cp3837-l_scripting_revitpythonshell_handout.pdf

Another link with PFD about:
Scripting Autodesk Revit with RevitPythonShell

About Python and Ruby:
http://thebuildingcoder.typepad.com/blog/2013/06/python-and-ruby-scripting-resources-and-the-sharp-glyph.html

Link to download Revit Python Shell:
https://github.com/architecture-building-systems/revitpythonshell

Links to learn programming in Python:
The Python Tutorial — Python 2.7.10 documentation
docs.python.org – newer versions of Python
http://www.diveintopython.net/

Python Macro template:
http://wiki.theprovingground.org/revit-api-py-setup

About Revit Macros:
https://www.augi.com/library/getting-started-with-revit-macros
https://www.augi.com/library/introduction-to-revit-macros

What’s the difference between macro and Add-in:
https://boostyourbim.wordpress.com/2012/12/05/macros-vs-add-ins-whats-the-difference/

My First Plug-in Training – Learn how to create  add-in with C# in Microsoft® Visual C# Express

http://help.autodesk.com/ – There is a part devoted to developers like you.

DevTV movie introduction to the Revit 2015 API

API – Application Program Interface
SDK – Software Development Kit

 * Still Revit is the best BIM software I know.

Good luck and have fun.