Set DataStorage Entity from external application

Set DataStorage Entity from external application

prakash.muthu
Advocate Advocate
615 Views
2 Replies
Message 1 of 3

Set DataStorage Entity from external application

prakash.muthu
Advocate
Advocate

Hi,

Exploring options to create DataStorage and set entity in Revit document from external application. After setting DataStorage entity need to save document. This need to be done running Revit instance in background. 

Currently could create storage and update entity in Add-In. But this need executed from separate exe.


The question is, How to start Revit instance from exe and access Revit API to update document storage entity.

0 Likes
Accepted solutions (1)
616 Views
2 Replies
Replies (2)
Message 2 of 3

jeremy_tammik
Alumni
Alumni

You can start Revit from an external EXE using Process.Start:

  

  

to create DataStorage, set entity in Revit document and save document

  

All of these steps require a valid Revit API context. One way to obtain that is to use an external event:

  

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 3 of 3

Mohamed_Arshad
Advisor
Advisor
Accepted solution

Hi @prakash.muthu 

 

I have a workaround for your task, Kindly check the below points.

  • Implement your Extensible storage helper methods in a static class.
  • Design a simple standalone application (exe) that starts Revit in a separate process.

 

static void Main(string[] args)
{
    string exeLocation = @"C:\Program Files\Autodesk\Revit 2023\Revit.exe";
    string arguments = @"/languageENG /runhidden /nosplash";

    ProcessStartInfo revitInfo= new ProcessStartInfo(exeLocation,arguments);
    Process.Start(revitInfo);
}​

 

  • In the OnStartup method your application implements, subscribe to ApplicationInitialized event.
  • When your add-in receives the event, open the document you want to add data storage by calling the helper methods.
  • When the document is opened, perform the process; output whatever you need to output.
  • Save and Close the document.
  • Exit the ApplicationInitialized event handler
  • When the standalone application receives the inter-process message from your add-in, kill the Revit process.

Hope this will Helps 🙂

 


Mohamed Arshad K
Software Developer (CAD & BIM)