Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

Is it possible to access/write to an open Revit session from an externally running .exe?

szhaoNAYVW
Explorer
Explorer

Is it possible to access/write to an open Revit session from an externally running .exe?

szhaoNAYVW
Explorer
Explorer

Let's say I have an app.exe that runs outside of Revit. Let's say this app generates a 3 x 3 array, and I want to import/draw this table in an active Revit session in a drafting view. 

 

I have created "commands" that start inside Revit that utilize the transaction method to draw lines and textboxes before. But is there any way to do this from an externally running .exe with the Revit API referenced in?

 

Any help would be greatly appreciated.

-Stephen

0 Likes
Reply
434 Views
5 Replies
Replies (5)

joshua.lumley
Advocate
Advocate

I don't think you can. However you can make an app that will work standalone as well as an addin (utilizing different constructors) meaning you can launch the thing from the task bar and the ribbon.  (I wrote one over Christmas).
But you can't perform a transaction to the project database outside of the Revit.exe process. Correct me if I'm wrong.

0 Likes

szhaoNAYVW
Explorer
Explorer

In that case I wonder if there's any way I can pass through some variables to the taskbar or ribbon function... That's too bad, it may require me to build the actual computational solution inside the ribbon function.

0 Likes

RPTHOMAS108
Mentor
Mentor

Numerous approaches exist. Do a search on this forum and elsewhere for 'interprocess communication' and 'driving Revit' and you may find some solution that meet your goals.

 

The key is having an insider raising an ExternalEvent to deal with an external request i.e. you have to have an addin that responds to an external action and raises the ExternalEvent. Since objects can be serialised in various forms json, xml; dropped by one process and picked up by the other the possibilities aren't that limited.

 

What could an insider addin look for:

Windows messages, file system events...

 

 

0 Likes

joshua.lumley
Advocate
Advocate

PipeStream Class (System.IO.Pipes) provides interprocess communication without the need for seralization. Although it may be better to pass variable via xml to avoid the necessity to have both applications open at the same time.

0 Likes

RPTHOMAS108
Mentor
Mentor

Yes there is the possibility to use named or anonymous pipes for this.

 

I didn't find them to be the easiest thing to work with when I tried (keeping them open and at the same time not thread blocking) they at least require a separate thread from Revit. Pipes are more straightforward when you have complete control over the client and server sides. The examples seem simple enough (the console application type examples) but not so easy when factoring in Revit. Then in the end what do you send through the pipe?

 

I got them working for a separate progress bar executable once in the early days when we were looking for ways of doing away with DoEvents. Revit was sending information through and the executable progress bar was acting upon it (this was in other direction). Got a lag which was a strange situation for a pipe.

 

As you say other methods I found more appealing due to their simplicity.