Detect other Revit versions open

Detect other Revit versions open

NonicaTeam
Enthusiast Enthusiast
670 Views
5 Replies
Message 1 of 6

Detect other Revit versions open

NonicaTeam
Enthusiast
Enthusiast

Hi!
Would anyone know a way to detect all the Revit versions open? I mean to know if Revit 2019 and 2020 are open and running when loading an Add-In from Revit 2021 for instance.
Thanks in advance

0 Likes
Accepted solutions (1)
671 Views
5 Replies
Replies (5)
Message 2 of 6

caroline.gitonga
Autodesk
Autodesk

Hi @NonicaTeam,

Thank you for asking this. If I may ask, is there a specific reason would you want to know other open Revit versions apart from the version your are running your add-in. In the meantime, I have asked the Dev team for you. Will let you know of the feedback. Thanks

Carol Gitonga, Developer Advocacy and Support, ADN Open
0 Likes
Message 3 of 6

caroline.gitonga
Autodesk
Autodesk
Accepted solution

Hi @NonicaTeam,

I got a response regarding this. Turns out this can be achieved by using .NET Process.GetProcesses Method which returns all the process resources running on the local computer. From the result you can locate whether there is any instance of Revit is running.

https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.process.getprocesses?redirectedfrom=M...

Kindly, let me know if this helps.

 

Carol Gitonga, Developer Advocacy and Support, ADN Open
0 Likes
Message 4 of 6

Kennan.Chen
Advocate
Advocate

I used to create something similar. I didn't think getting revit version from process info is reliable so I handled it myself.

 

First thing to make sure is that your add-in is well installed on every version of revit.

Then you'll need to implement an executable to act as a central service(http, namedpipe, grpc, WCF, whatever). You also need to make sure the service can only have one running instance(use Mutex to achieve this). Or you can simply use a file instead.

Whenever a revit instance starts up, your add-in should try to start the central service and register the current running revit info into that service. And you should unregister it while revit shuts down.

When a new revit instance starts up. You can get a list of running revit info from the central service.

 

I used this feature to send an .rfa file from a standalone application to the revit instance that user selected.

Message 5 of 6

NonicaTeam
Enthusiast
Enthusiast
Thank you very much!
Message 6 of 6

NonicaTeam
Enthusiast
Enthusiast
Thanks for your help!