"Save to New File..."

"Save to New File..."

TimonHazell-WPM
Contributor Contributor
3,581 Views
4 Replies
Message 1 of 5

"Save to New File..."

TimonHazell-WPM
Contributor
Contributor

I have searched a few websites without any direct solution so I thought I'd ask here:

 

Is the "save to new file" right click option open in the API?  In the user interface you can right click on a view in the project browser and "save to a new file."  Otherwise, I'm guessing I will have to either open a new document and copy the views into that document.  or Save AS and purging the document.

 

Thanks in advance.  My end goal would be to either export a selected list of drafting views to a single or individual files.

 

0 Likes
Accepted solutions (1)
3,582 Views
4 Replies
Replies (4)
Message 2 of 5

jeremytammik
Autodesk
Autodesk

Dear Timon,

 

Thank you for your query.

 

There are a number of obvious simple places to check before searching the Internet.

 

Start with the Revit API help file, RevitAPI.chm, also available online at

 

http://www.revitapidocs.com/

 

Also, I hope you have installed the Revit SDK and samples.

 

Always look through the SDK sample collection.

 

All you need to get started is in there.

 

Anyway, to answer your question:

 

The Document class SaveAs method does exactly what you need:

 

http://www.revitapidocs.com/2017/25c44d4a-b220-5898-b28c-a2cf6a8a8673.htm

 

I hope this helps.

 

Best regards,

 

Jeremy



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

0 Likes
Message 3 of 5

TimonHazell-WPM
Contributor
Contributor

Jeremy,

 

Thank you for your reply. I think I'm either missing something obvious. (is there a way to construct a document with selected views all the "export" seem to go to alternate software packages)

 

I am not trying to just save the file as a new file (although, I think now my subject was a little vague).  I am trying export a bunch of drafting views to a new file. In the UI there is a right click option under each view in the project brower to "save the view as a new file"

 

I had searched the Revit API docs (thank you Gui Talarico)  and the building coder (thank you) and came up with one of the following workflows:

 

1. NewProjectDocument

2. ElementTransformUtils.CopyElements (http://thebuildingcoder.typepad.com/blog/2013/05/copy-and-paste-api-applications-and-modeless-assert...)

3. SaveAs

 

or

 

1. SaveAs

2. Purge/Delete

3. Save

 

Both Seemed a little clunky.  I think I prefer the first option (although until 2016 it looks like it requires a template, which users should have installed on their computers under the default blank imperial template)

0 Likes
Message 4 of 5

jeremytammik
Autodesk
Autodesk
Accepted solution

Dear Timon,

Thank you for your update and clarification.

 

I would suggest trying the first approach you describe to begin with.

 

And before that, take a look at the DuplicateViews SDK sample. Its readme says:

 

Use the copy paste APIs to copy drafting views and schedules from one document to another. The drafting view contents will also be copied.

I hope this helps.

Best regards,

Jeremy



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

0 Likes
Message 5 of 5

TimonHazell-WPM
Contributor
Contributor

Jeremy, 

 

Thank you for your help. 

 

Blessings,

Timon

0 Likes