Today, I am presenting a class on Design Automation for Revit or DA4R at the Forge DevCon preceding the German Autodesk University in Darmstadt.
I will present very similar material again tomorrow in German in the AU session on BIM360 News und Online Revit-Programmierung von BIM via Forge Design Automation API für RVT.
This is all based on last year's presentation SD125457 – Design Automation – Building Web Applications with Revit Data on Forge by Diane Christoforo, Sasha Crotty, Rahul Bhobe and Ryan Duell at Autodesk University last year in Las Vegas.
I consider that enough public exposure to allow me to share this information here with you as well:
It will also help me get my act together for the two presentations :-)
For your convenience, here are the AU 2017 slide deck and handout document in PDF format:
Please refer to the further reading material for a link to the session recording.
Forge Design Automation API for Revit is an unreleased service which is currently in invitation-only beta. The information presented here will change.
Any statements regarding planned or future development efforts are not intended to be a promise or guarantee of future availability of products, services or features but merely reflect current plans and based on factors currently known. These planned and future development efforts may change without notice. Purchasing decisions should not be made based upon reliance on these statements.
Please note that you currently cannot make any practical use whatsoever of anything discussed below.
The Forge Design Automation API for Revit lets you build web applications that create, read, and modify Revit models. We'll review the kinds of apps you will be able to build and their API architecture so that you can get ready to use Design Automation for Revit in your own applications.
Design Automation API for Revit is a Forge service that will allow developers to access the 'business logic' of Revit on the cloud. Like Design Automation API for AutoCAD, developers can create client applications which speak to the Revit engine via our REST API. Developers will be able to automate existing workflows or create new cloud workflows.
Because Design Automation API for Revit is a Forge service, you can take advantage of other Forge services to easily connect your applications together.
Today, you can use and read the existing documentation for Design Automation API for AutoCAD.
There are many options falling under three major workflows: Create, Extract, and Modify.
Create:
Extract:
Modify:
Like other Forge services, you’ll create a Forge client application which will call our REST API endpoints. You can use any language which can make REST calls. This client application will also do any 'front-end' work you need – displaying UI to an end-user, for example. Overall, the system is similar to Design Automation API for AutoCAD and the endpoints should be familiar to someone familiar with that service.
In addition to the client application, you will create one or more Revit add-ins to execute against the Revit engine. You will upload these to the Design Automation service and your client application will refer to them when invoking the service. (You can keep them private or public depending on what you want.) We’ll talk more about these add-ins in the next section.
There are a few important things to keep in mind as you plan for how to use the service.
Your full client application may not be a Revit add-in specifically. It may be a website or a standalone application. But part of your system will be a Revit add-in. This add-in is what will be executed against Revit in the cloud when you invoke the Design Automation API.
Even though the Forge service isn’t public today, we can explain the steps to create a Design Automation-ready add-in now. You can use these steps to convert an existing add-in or to create a new one.
When you send a job to Design Automation API, it will go into a queue. When it reaches the head of the queue, it will run to completion and then return. Everything the job needs to run must be available to it at start time. As such, add-ins should be able to do self-contained chunks of work.
This does not mean the add-in can only do simple tasks, just that all the inputs need to be present up front. For example, take an add-in which does nightly data extraction from a model. It might export all views to images, convert all schedules into the company’s format, create charts on what changes have happened in the model over the past day, and update cost estimates. You could structure this as one add-in or as four, depending on what you want to do and whether you think you might reuse the pieces elsewhere. One add-in means only having to open the model once. Four add-ins lets your client application send the work as four different jobs and you may get intermediate results faster.
Most Revit add-ins are external commands (IExternalCommand) or external applications (IExternalApplication.) There is a third kind, the IExternalDBApplication, which is an add-in which can run without Revit’s UI logic. You will not have access to Revit’s UI logic as part of Design Automation API, so you will need to create an IExternalDBApplication.
Your add-in will have access to all the functionality in RevitAPI.dll but none of the functionality in RevitAPIUI.dll. You should avoid using other UI libraries as well. There is no way to click on dialogs or message boxes; the system will effectively hang if you try to present one.
If you have an existing app, splitting into UI and logic layers will allow you to run against both desktop Revit and Design Automation API. You can preserve your existing UI functionality within an IExternalApplication which communicates with your IExternalDBApplication.
'Inputs' to a Design Automation job can include simple parameters and files of any type. The framework will put any input files into the cloud machine’s working directory before running your add-in.
As mentioned, a Design Automation job must have all the information it needs to run at launch time. There is no ability to send more data or call back to the user in the middle of a job. This can present a problem if your add-in expects to do partial calculations and then ask the user for more input.
In this situation, you can either attempt to collect the input up front, or set up your client application so that it run several smaller jobs. Here are two examples:
We will provide a small library with an event your add-in can subscribe to in order to be notified when the Design Automation service is ready to run your add-in. Your add-in should create an event handler and execute its functionality inside. (The add-in will be registered in Revit normally, but this provides an entry point for starting your code.)
Until the library is available, you can get a similar effect for testing purposes by subscribing to Revit’s ApplicationInitialized event. You should not do this if you are actually running your add-in against Design Automation, because we will do more system setup after the ApplicationInitialized event is raised. Additionally, the framework will use the success/failure parameter of the event to determine whether the job succeeded.
One side effect of there being no UI available is that you will need to handle Revit errors. We will ignore or take a default action for user-facing dialogs. We will also ignore warnings. However, we do not take any default actions for errors. You should either create an event handler for the FailuresProcessing event, or implement an IFailuresProcessor.
You must ensure that it handles all possible warnings, errors and other failures gracefully.
The Building Coder recently discussed this topic using the StairsAutomation SDK sample:
FailureProcessor.cs
Design Automation API for Revit does not have any built-in logging functionality. You can add comments to the Revit journal via Application.WriteJournalComment(). You can also create a log file of your own and include it in your output zip package.
During your add-in’s execution, you will only have access to the working directory of the cloud machine. As such, any Revit models or other files you create will need to be saved to the working directory, or to a subfolder under the working directory. This also applies to any log files you create.
You can specify input files from cloud locations by providing a signed URL when running a Design Automation job. The framework will download the file or files to the working directory.
Your Revit add-in will not have access to the network. Any cloud files you need will have to be specified as inputs. The Design Automation framework will take care of downloading any input files before running any Revit code. The service will also upload your output to the URL you specify.
If you need to communicate with an online database or something similar, your client application will need to do this before your after your add-in runs. You may need to temporarily store your data in an input or output file.
Here are links to the current Forge Design Automation API reference (for DWG), Revit API guides and past online AU classes for Design Automation:
Design Automation API Reference:
Revit API:
Past Autodesk University Classes:
Design Automation lets you write your own applications for Revit, so that you can process and manipulate Revit models via Autodesk Forge.
Please follow these steps to run your first Revit job in Design Automation:
Before we discuss any details, let's define some important terms:
Client Id
to a customized string. The nickname lets you create a friendly, easy-to-read, string that can be used in place of the long Forge App Client Id
.app
or activity
.apps
.activity
. The relationship between an activity and workitem can be thought of as a 'function definition' and 'function call', respectively. The naming rules for nickname
, alias
and id
of app
/activity
limit the possible characters to the purely alphnumerical set of [a-zA-Z_0-9].
Before you convert your Revit add-in to DA4R, you must ensure that it handles all possible warnings, errors and other failures gracefully.
The Building Coder recently discussed this topic using the StairsAutomation SDK sample:
FailureProcessor.cs
forge use cases - general categories
dashboard and data visualisation analysis + simulation saas integration batch editing of designs ar + vr configurators content catalogues photogrammetry