How to Batch Process Revit Files with Addin

How to Batch Process Revit Files with Addin

wence.sui
Explorer Explorer
2,881 Views
4 Replies
Message 1 of 5

How to Batch Process Revit Files with Addin

wence.sui
Explorer
Explorer

Hello all,

 

I'm new in Revit and Revit APIs, I developed a Revit Addin (Externcal command) that dump project parameters and their values into SQL database. It works fine in Revit UI.

 

Now I need to process a list of Revit files with my Addin. So how can I achieve that? Does Revit support command lines to start up with a Revit file opened automatically and run an Addin automatically?

 

Any helps and suggestions appreciated, thanks.

0 Likes
Accepted solutions (1)
2,882 Views
4 Replies
Replies (4)
Message 2 of 5

ABertzouanis9F98Y
Enthusiast
Enthusiast

Hope this helps.

void RunCommandInMultipleModels(List<string> revitModelPaths)
{
	foreach (string modelFilePath in revitModelPaths)
	{
		//Open Document
		OpenOptions opt = new OpenOptions();
		ModelPath modelPath = ModelPathUtils.ConvertUserVisiblePathToModelPath(modelFilePath);
		UIDocument uidoc = uiapp.OpenAndActivateDocument(modelPath, opt, false);
		Document doc = uidoc.Document;
		
		//Close Previous Document
		if (previousDoc != null)
			previousDoc.Close(false);

		//Here you run your Addin
		RunMyRevitAddin(doc);

		//Previous Doc assignment
		previousDoc = doc;
	}
}

 

Message 3 of 5

jeremy_tammik
Alumni
Alumni
Accepted solution

Welcome to Revit and the Revit API.

 

Please note that diving into the API with little or no end user experience will make it a lot harder for you to understand (and accept) why things are the way they are. So, a bit of product experience will definitely help. Here are some recommendations and pointers on getting started:

 

 

Yes, Revit supports passing in the RVT file to process on the command line.

 

Revit also supports journal files which enable you to reproduce certain sequences of input events and command executions; however, that support is not official for customisation purposes.

 

The Building Coder discusses both of these topics and more:

 

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 4 of 5

wence.sui
Explorer
Explorer
Thanks a lot for your reply. The reason I need a command line solution is that I need to run it on scheduled task. Your suggestion is still helpful. Thanks.
0 Likes
Message 5 of 5

wence.sui
Explorer
Explorer

Thank you very much Jeremy, this is exactly what I'm looking for! This "RevitBatchProcessor" utility totally meets my needs. I'll dig into the source codes to be familiar with Revit APIs. Really appreciated your help, thanks again.

 

BTW, terribly sorry for late reply because I was assigned to a priority job as soon as I posted this question.

0 Likes