In our previous discussion on the Revit API, we reviewed the concept of using the Revit API to craft a plugin to extend the out-of-the-box functionality within Revit. Conceptually speaking, the Revit API is a library of definitions and protocols that can be interacted with through a programming operation to create a capability within Revit. Once one understands the basic premise of creating a Revit plugin, the logical next step is to consider the methods available to undertake the actual “programming” of the plugin.
Traditionally, programming has been the domain of people with extensive knowledge of software development languages. For someone without that background, desired information may be scarce and hard to find, appear overwhelming due to the sheer volume of content available and/or can be difficult to access and understand once found.
However, as use of applications and computer programs for work and leisure activity has grown and continues to grow exponentially, application users are similarly increasing in number and, more importantly, increasing in knowledge. This increasing knowledge and comfort with technology often leads to “everyday users”, those without deep programming backgrounds, originating wonderful ideas for new software or improvements to existing software. These users are often comfortable enough with technology to “give it a try”. This growth in incidence of technology in everyday life coupled with an ever-more adventurous, idea filled, technologically savvy user populace then naturally leads application developers to continue to evolve their offerings as well.
Coinciding with this, the actual programming systems behind these applications are also evolving. Many applications that support programming through an Application Programming Interface (API), are also incorporating visual programming - a method allowing users to create tools and programs by working with program components graphically as opposed to building them in a traditional text-based coding methodology. Visual programming is a method meant to allow users to attempt to bring an idea to fruition without relying on a traditional programming language. Autodesk and Revit are no strangers to this trend and, in recent versions of Revit, they are incorporating this concept of visual programming. Specifically, Dynamo represents the visual programming technique most often used to build for these applications with their APIs.
This advent of visual programming, appearing as a simpler method for development, may lead to the assumption that it is not necessary to know how to program in the traditional sense, and in a certain way it is true. We don't necessarily need to know how to directly write code to accomplish our goal but we do need to know the API for the tool, such as Revit, that we are working with and we must be aware of both the benefits and limitations inherent in visual programming.
With this baseline of understanding we see that there are two primary programming techniques to interact with the Revit API in order to build capabilities for Revit:
While representing a more accessible method to develop capabilities, there are notable concerns:
Dynamo can actually be supplemented through the use of code written in various languages. A developer can create a capability in a traditional programming language and incorporate it into a Dynamo process as a node. This, however, contradicts one of the primary conceptual benefits of Dynamo - the ability to build functionality without needing to have programming knowledge.
In our experience, using Dynamo to extend the capabilities of a package like Revit can work very well for smaller or limited complexity automations, but from there it gets complicated.
Since its inception Revit has exposed its API to the public allowing developers to create plugins to enhance and extend Revit’s capabilities.
The primary methods to “program by code” in Revit include:
Revit plugins are normally written in the .NET platform, with plugins created in any of the languages supported by .NET also supported by Revit. The most frequently used .NET languages in use for crafting Revit plugins, all of them being object-oriented languages, are:
The basic syntax of C# .NET derives from C/C++ but operates on the .NET framework and includes improvements and capabilities derived from other languages. The many innovations of C# .NET allows you to develop applications quickly while maintaining the expressiveness and elegance of C.
The name C# (C Sharp) was actually inspired by the ♯ sign in musical notation. It is a play on words since, musically speaking, the symbol # indicates that a note, in this case C, must be a semitone higher. This is a metaphor for the higher capability or superiority of C# over its predecessor C++ which used the ++ symbols to allude to its superiority over C. Furthermore, the # symbol can be imagined as the union of four + symbols, continuing the sense of progression of the C languages.
Unlike Dynamo but similar to VB.NET, C# is a language where written code must be “compiled”. The C# compiler compiles the C# source code into Microsoft Intermediate Language (MSIL) with that code recompiled to the native format on the machine and Operating System it will run on. We can think of this as a two-step build with the output being an executable program that can then be incorporated into the Revit environment.
In our experience the best option for programming plugins for Revit is currently C#. This opinion is based on several factors:
While C# is generally our favored plugin development approach, one potential scenario in which we may recommend C++ over C# would be when your application executes a significant volume of calculations. In this case it may be beneficial to use C++ as its speed of operation in calculation-intensive functions may sometimes be superior to C#.
Regardless of the above considerations, the best choice of one methodology or language over another is the one with which you are most comfortable or familiar. The options to build functionalities are many, with a widely varying degree of prerequisite knowledge. The true benefit of having these choices available is the existence of the ability to incorporate new capabilities and to enhance or extend features of a tool like Revit.
Voyansi’s software team offers services to build Revit plugins to your specification in any of the technologies discussed. Additionally, Voyansi offers training on Dynamo for the user who wishes to try their hand at building features themselves. Contact us to discuss your ideas and needs!