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: 

Rename Revit Document

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Anonymous
1008 Views, 5 Replies

Rename Revit Document

Hi y'all!

 

Let's say that the user has a Revit Document open in my Application, but he/she has named it incorrectly (or better said, not accordingly to our internal naming convention).

Now, I'm creating a plugin that generates the correct name and path from some user inputs (through a UI) and I want to change the name of the Document on the fly, to the generated name.

 

I tried with this:

string generatedName = GenerateName();
uiApp.ActiveUIDocument.Document.Title = generatedName;

but then I found out that the property Title doesn't have a get accessor, hence I can't do the above.

 

What would be the best way to achieve this?

 

Thanks!

5 REPLIES 5
Message 2 of 6
jeremytammik
in reply to: Anonymous

Do you mean set accessor?

 

The title is associated with the file name, isn't it?

 

Maybe you have to close the model, rename the file, and reopen the model from the newly named file.

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 6
Anonymous
in reply to: jeremytammik

Yeah sorry I meant set accessor!

 

And yes, the title is pretty much the file name without the .rvt extension.

 

On closing an renaming the file: I guess I wouldn't be able to do it probrammatically from a Revit button / IExternalEvent (triggered by a Dockable Panel), would I?

Message 4 of 6
RPTHOMAS108
in reply to: Anonymous

In the UI if I wanted to rename a file I wouldn't close it and rename it I'd SaveAs and delete the old one...

 

Document.SaveAS

 

You should also consider if you are working with the central file or the local file?

Message 5 of 6
jeremytammik
in reply to: Anonymous

I like Richard's suggestion better.

 

However, you can close the active document if you really want to:

 

https://thebuildingcoder.typepad.com/blog/2012/12/closing-the-active-document.html

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 6 of 6
Anonymous
in reply to: jeremytammik

Yeah I thought of the SaveAs option too. I guess it's the best option.

 

Thanks guys!

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

Post to forums  

Rail Community


Autodesk Design & Make Report