24ADF-Eelu
24ADF-Eelu

Reputation: 1

I need to programmatically access the current Autodesk.Revit.DB.Document and ActiveUIDocument from the opened project within my WinForms application

I've developed an IExternalCommand add-in for Revit. Now, I've created a new WinForms project with a button that automatically opens a Revit project file using

System.Diagnostics.Process.Start("C:/tmp/wall.rvt");

I need to programmatically access the current Autodesk.Revit.DB.Document and ActiveUIDocument from the opened project within my WinForms application. Essentially, I want to trigger the add-in's functionality directly from my WinForms app, just as it would be when manually invoked from the Revit ribbon. Is there a way to achieve this?

Upvotes: 0

Views: 88

Answers (1)

Jeremy Tammik
Jeremy Tammik

Reputation: 8339

I answered your question in the Revit API discussion forum here and here. I repeat the gist of the answer as follows:

You can use an external event to achieve what you ask for.

Many aspects of how to do so have been discussed by The Building Coder in the topic group on Idling and External Events for Modeless Access and Driving Revit from Outside.

Pay attention to the last couple of entries in the topic group list. They refer to very recent discussions in the Revit API discussion forum and completely answer your question.

Upvotes: 0

Related Questions