how to capture the name of the file revit

how to capture the name of the file revit

Anonymous
Not applicable
537 Views
4 Replies
Message 1 of 5

how to capture the name of the file revit

Anonymous
Not applicable

Hi everyone

I am developing an addin revit, I need to capture the file name in a string variable when opened, someone has any idea how to do it?
0 Likes
Accepted solutions (1)
538 Views
4 Replies
Replies (4)
Message 2 of 5

arnostlobel
Alumni
Alumni
I assume you want to get to the name of a document an end user opens in Revit (via the UI File Open Dialog, or by drag and dropping) or another API application opens it using the Application.OpenDocumentFile method. If my assumption is correct, then the Application.DocumentOpened event is the solution you are looking for. The document that has just been opened will be available via the arguments of the event handler, and there you use either PathName or Title property depending on what you need.
Arnošt Löbel
0 Likes
Message 3 of 5

Anonymous
Not applicable

Tanks Arnošt

Exist example to use Application.DocumentOpened event? help me please! 

 

Regards

0 Likes
Message 4 of 5

arnostlobel
Alumni
Alumni

There is a good chance such a sample exists. Start searching in the Samples folder provided with the SDK. There are definitelly samples of using various events, and it is very likely the DocumentOpened is among them. If not there, search the web with a simple "Application.DocumentOpened" query string - it should bring some samples, for this particular event is very often used by Revit programmers. 

Arnošt Löbel
0 Likes
Message 5 of 5

Anonymous
Not applicable
Accepted solution

Hi everyone.

this is the answer to my request:

 


Dim uiapp As UIApplication = commandData.Application

 

uiapp.OpenAndActivateDocument("C:\example.rvt")

Dim FileOpened as String = commandData.Application.ActiveUIDocument.Document.PathName()

 

Regards!!!

0 Likes