2024 Method
Changes 0
M

Document.SaveAs

Description:
Saves the document to a given file path.
Remarks:

This method may not be called unless all transactions, sub-transactions, and transaction groups that were opened by the API code were closed. That also implies that this method cannot be called during dynamic updates. Event handlers are not allowed to save document that are currently in modifiable state.

If options.rename is true, then the document's title in Revit's title bar will be updated automatically to reflect the file's new name.

Overloads (3):
SaveAs(String,SaveAsOptions)
public void SaveAs(
	string filepath,
	SaveAsOptions options
)
  • String
    filepath
    File name and path to be saved as. Either a relative or absolute path can be provided.
  • options
    Options to govern the SaveAs operation.
// Get the document's preview settings
DocumentPreviewSettings settings = document.GetDocumentPreviewSettings();

// Find a candidate plan view
FilteredElementCollector collector = new FilteredElementCollector(document);
collector.OfClass(typeof(ViewPlan));

Func<ViewPlan, bool> isValidForPreview = v => settings.IsViewIdValidForPreview(v.Id);

ViewPlan viewForPreview = collector.OfType<ViewPlan>().First<ViewPlan>(isValidForPreview);

// Save the document
SaveAsOptions options = new SaveAsOptions();
options.PreviewViewId = viewForPreview.Id;

document.SaveAs(@"c:\renamed_family.rfa", options);