Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to capture the name of the file revit

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Anonymous
377 Views, 4 Replies

how to capture the name of the file revit

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?
4 REPLIES 4
Message 2 of 5
arnostlobel
in reply to: Anonymous

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
Message 3 of 5
Anonymous
in reply to: arnostlobel

Tanks Arnošt

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

 

Regards

Message 4 of 5
arnostlobel
in reply to: Anonymous

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
Message 5 of 5
Anonymous
in reply to: Anonymous

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!!!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community