Design Automation For Revit – Part 2

Amazing! Design Automation For Revit – Part 2

Information about Design Automation For Revit – Part 2

Phil Puccio

After the first part, where we explore how to create a Revit add-in for the Design Automation API, we can now upload that add-in and run it on the Forge server.

Now that we’ve created a new Forge app using the Data Management API and the Design Automation API, we’ll use the Postman definitions provided here to create our design automation application.

We need to create a bundle, a package that contains our Revit add-in, to upload to the cloud. We’ll create the folder structure in our solution and then add the following to the post build event in Visual Studio

xcopy /Y /F "$(TargetDir)*.dll" "$(ProjectDir)IFCExport.bundleContents"
xcopy /Y /F "$(ProjectDir)*.addin" "$(ProjectDir)IFCExport.bundleContents"
"C:Program Files7-Zip7z.exe" a -tzip "$(ProjectDir)$(OutputPath)" "$(ProjectDir)IFCExport.bundle" -xr0!*.pdb

Used this little script 7-zip to create a zip file that contains the folder structure and application files (.dll and .addin)

We then register an AppBundle on the Forge server, where we upload the bundle ZIP file with our Revit add-in.

We now need to create an activity. An activity is a function definition that you create on the Forge server before you run it. In this activity we add the AppBundle created in the previous step and describe input and output files with the following JSON text:

    "commandLine": [ "$(engine.path)\\revitcoreconsole.exe /i $(args[rvtFile].path) /al $(appbundles[IFCExportApp].path)" ],
    "parameters": {
      "rvtFile": {
        "zip": false,
        "ondemand": false,
        "verb": "get",
        "description": "Input Revit model",
        "required": true,
        "localName": "input.rvt"
      "param": {
        "zip": false,
        "ondemand": false,
        "verb": "get",
        "description": "Json Parameter file",
        "required": true,
        "localName": "params.json"
      "result": {
        "zip": false,
        "ondemand": false,
        "verb": "put",
        "description": "Results",
        "required": true,
        "localName": "IFCExport.ifc"
    "engine": "Autodesk.Revit+2021",
    "appbundles": [ ".IFCExportApp+test" ],
    "description": "Export a Revit file to IFC."

This Json text describes the behavior of our activity:

  • The engine used: Here Revit 2021
  • The name and description of the input files. Here we have a Revit file called input.rvt and a json parameter file called param.json
  • The name and description of the issue. Here we have an IFC file called IFCExport.ifc

We also need to create an alias, a name, for the activity because Forge doesn’t allow us to call an activity by its ID, only by its alias. I create the alias “test”. This function can also be used to call up a specific version of an activity (test, production, …).

Now that our activity has been created, our application is ready to receive the entered Revit model. To upload it to the Forge server, we need a public url pointing to our Revit file. To create such a URL, we will use the Data Management API and create a bucket to temporarily store our Revit model. We then get a temporary upload url which we pass to the Data Management API to get our uploaded Revit model.

In this memory we also receive a temporary download URL that the Data Management API uses to save the result of our application, in our case the CSV file with the schedule.

We are now ready to run our application on the Forge server. We create a WorkItem (an instance of an activity described earlier) and pass it the URL of the RVT input file along with a URL to upload the exported IFC model.

After some trial and error, I get this answer:

    "status": "success",
    "reportUrl": "",
    "stats": {
        "timeQueued": "2020-08-26T19:52:13.8851515Z",
        "timeDownloadStarted": "2020-08-26T19:52:14.4542928Z",
        "timeInstructionsStarted": "2020-08-26T19:52:15.3584001Z",
        "timeInstructionsEnded": "2020-08-26T19:54:14.3353297Z",
        "timeUploadEnded": "2020-08-26T19:54:14.4511254Z",
        "timeFinished": "2020-08-26T19:54:14.6601308Z",
        "bytesDownloaded": 18907171,
        "bytesUploaded": 4344
    "id": "327ecd7e417d4146ac9fee526dadc77a"

I then take the download url that is used to save the result, download it and get the resulting IFC conversion.

At first glance, this application seems slow. I used the normal architecture sample file for this experience (18 mo). It takes 2 minutes and a second to run the entire WorkItem. The download part is actually very quick (2 seconds to upload the Revit model, a tenth of a second to download the resulting conversion). However, it takes 1:59 to open the model and run the app on the Forge server. My Surface Book 2 only takes 54 seconds to run. Subsequent runs were faster though, I suspect the server may take some time the first time it starts.

The Design Automation API allows multiple linked files to be uploaded with a standard error handler that allows us to manage the annoying Revit warnings we sometimes get when we open a file. However, a warning that it must delete elements to be resolved prevents the Design Automation API from opening the file and sending back an error.

Nevertheless, it opens up many possibilities. You can now basically do anything with a Revit file without opening Revit on your workstation, and I see a bright future for web-based applications that use Revit files.

Breaking Story – Design Automation For Revit – Part 2

The Latest News on Design Automation For Revit – Part 2

Original Source:
Category – BIM

Leave a Reply

Your email address will not be published.

© 2022 - WordPress Theme by WPEnjoy