fbpx

Revit headless. In the pursuit of the mythological beast

Creating pipelines of information

As you can see in our article about data warehouses, moving data is our bread and butter at e-verse. Most projects we work on involve using Revit models as a source of information. We extract the model’s metadata and geometry to process and deliver it to new environments.

To extract the information, you rely on opening your model manually using Revit or creating a bundle with your add-in and sending it to Autodesk’s Service platform’s Design automation API. The first option involves user interaction, which can take a lot of time and is prone to human error, and the latter involves costs, as you have to pay Forge credits for the processing time on the cloud.

Some time ago, we heard about a way to run Revit locally without UI, like a secret whispered in the dark side of conferences. Few knew it existed, but no one could explain how it works.

Finally, someone pointed us in the right direction, and then we could see why it was so difficult.

Opening a model file involves user interaction and rendering the interface of using Cloud services

Why is it important to run a headless Revit instance?

Automation.

You can run Navisworks without a UI to federate your files on schedule.

Unity can be executed on a backend and use its navigation agents to search for a shortest path without rendering geometry.

You can run Rhino Inside along with other software to access its geometry library, let’s say, in Autocad, Illustrator, and even Excel.

Industry software that can run headless v the ones that can’t

Multiple options are open once you are free of a user interface. You can do batch processing, deploy on the cloud, and unit testing, to name a few automation.

What about Revit?

Revit is proprietary software, therefore, uses proprietary binaries to store the information, which means the only way to access it is through the application itself.

While being a great program, opening a model manually comes with some downsides:

  • It takes considerable time to open the file if your model is big,
  • You cannot read or modify the information in the model without opening it with a Revit instance.
  • While you can automate some parts of the process, opening a Revit model uses a lot of resources from a machine to load all the information.

But when you only need to test, automate extensive processes, or do a quality check on your models without user interactions (at least in the UI), all these are perfect examples of workflows that can run on schedule with no interface.

This is why most developers try to run software from a command line: Let me check if my change in the code affected something else in the solution, extract only the data I need, and change the file with the latest information. All this should happen without having to click or see the software running.

There are a few alternatives.

While these allow running automation, you still will open and show the UI to execute Revit.

So no Revit headless out of the box?

Kind of. You can use the application RevitExtractor created by Autodesk to export a database, pdfs, and SVFs from your model without opening any UI.

				
					# Usage: RevitExtractor.exe [index.json / output folder] [input file] [-RCEPath path]
C:\Program Files\Autodesk\Revit 2022\RevitExtractor>RevitExtractor.exe "C:\Users\everse\Downloads\\" "C:\Users\everse\Downloads\FireStation.rvt"
				
			

If you want to do your own implementation, Revit has libraries that help you build tools on top of the vanilla software, such as RevitAPI.dll, RevitAPIUI.dll, and, among others, RevitNET.dll.

This last library exposes a different API allowing the user to initialize Revit from third-party code (your code).

				
					Product revitInstance = Autodesk.Revit.Product.GetInstalledProduct();
ClientApplicationId clientId = new ClientApplicationId(Guid.NewGuid(),
		 "testing",
		 "ADSK.Username",
      LanguageType.English_USA);
revitInstance.Init(clientId,
	 "I am authorized by Autodesk to use this UI-less functionality.");
				
			

In Revit versions 2018 to 2021, after resolving some dependencies and initiating the application, you could open documents and execute queries and transactions.

				
					var Document = revitInstance.OpenDocumentFile(filePath);
using (var transaction = new Transaction(Document, "Do something"))
{
    transaction.Start();
		//magic goes here
		transaction.Commit();
}
				
			

You can see from the disclaimer on the clientData in the Init method that, while not encouraged, Autodesk previewed particular uses for this API from third-party providers.

We assume partners were able to create their own pipelines of information.

But everything changed when the Fire Nation attacked

Since version 2022, Autodesk made clear this workaround was against their usage policies.

We believe it was after a problem with developers using it on programs not approved by Autodesk. Who knows.

You can see they discourage its usage directly from the API itself.

				
					Product revitInstance = Autodesk.Revit.Product.GetInstalledProduct();
ClientApplicationId clientId = new ClientApplicationId(Guid.NewGuid(),
		 "testing",
		 "ADSK.Username",
      LanguageType.English_USA);
revitInstance.Initialize_ForAutodeskInternalUseOnly(clientId,
	 "I am an Autodesk Product authorized to use this UI-less functionality."
+   "Unauthorized use is a violation of the Autodesk Terms of Service.");
				
			

The Init method was replaced with a clear statement establishing this is only for internal use, and the clientData string now is really clear on which type of use is expected.

The future

We imagine a future where all software is executed on the cloud, seamlessly integrated with other applications, or in different environments to democratize access to information.

  • Revit as a Service running on one of our AWS lambda function, waiting to process a file and connected with other services.
  • Revit connected to a pipeline inside Blender to create awesome renders and animations.
  • Revit into Bluebeam to create a BIM model from markups on a pdf.
  • Create web access for Revit to be able to use it on mobile devices.
  • Create a custom UI to build on top of Revit and being able to execute it on Linux using Wine.
  • A lot more ideas.

In conclusion

But as you can see, there is no way to run your own implementation of Revit Headless without failing Autodesk’s terms of service at the moment.

We suspect they use something similar to the RevitExtractor to process models on Forge and is understandable they don’t want to allow users to use it as this is a paid service.

This doesn’t mean the end of the road. Together with the whole AEC community, we are working in new ways to make the testing process smoother. Here a few examples:

As you can see there are a few venues to check regarding loading the minimal UI, not rendering views while processing, and a few more ideas to run Revit on any machine.

Stay tuned. Things may change in the future!

2074 Views

https://e-verse.com

DESIGN PROCESS ACCELERATORS FOR THE AEC INDUSTRY. e-verse's main expertise is to automate, streamline, and connect every stage of the design process, building solutions to help your business grow at a faster pace by leveraging technology. As architects and engineers who code, they transform your design construction requirement into accurate solutions that fit your needs.