Rename Revit Document

Rename Revit Document

Anonymous
Not applicable
1,993 Views
5 Replies
Message 1 of 6

Rename Revit Document

Anonymous
Not applicable

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!

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

jeremytammik
Autodesk
Autodesk

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

0 Likes
Message 3 of 6

Anonymous
Not applicable

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?

0 Likes
Message 4 of 6

RPTHOMAS108
Mentor
Mentor
Accepted solution

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?

0 Likes
Message 5 of 6

jeremytammik
Autodesk
Autodesk

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

0 Likes
Message 6 of 6

Anonymous
Not applicable

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

 

Thanks guys!

0 Likes