Assembly: RevitAPI (in RevitAPI.dll) Version: 2015.0.0.0 (2015.0.0.0)
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.
// 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);
' Get the document's preview settings Dim settings As DocumentPreviewSettings = document.GetDocumentPreviewSettings() ' Find a candidate plan view Dim collector As New FilteredElementCollector(document) collector.OfClass(GetType(ViewPlan)) Dim isValidForPreview As Func(Of ViewPlan, Boolean) = Function(v) settings.IsViewIdValidForPreview(v.Id) Dim viewForPreview As ViewPlan = collector.OfType(Of ViewPlan)().First(isValidForPreview) ' Save the document Dim options As New SaveAsOptions() options.PreviewViewId = viewForPreview.Id document.SaveAs("c:\renamed_family.rfa", options)
|Autodesk.Revit.Exceptions ArgumentException||filepath is an empty string. -or- The specified filepath is invalid. -or- options.PreviewViewId is not valid for generation of a preview. -or- The document is not workshared, so no WorksharingSaveAsOptions are allowed to be set for SaveAs. -or- The document just had worksharing enabled or was opened detached, so WorksharingSaveAsOptions.SaveAsCentral must be set to true for SaveAs. -or- Revit cannot clear the transmitted flag. This is not a transmitted document.|
|Autodesk.Revit.Exceptions ArgumentNullException||A non-optional argument was NULL|
|Autodesk.Revit.Exceptions CentralModelException||Central model is missing. -or- Central model is incompatible. -or- The central model was saved in a different version of Revit. -or- Revit encountered errors while saving to the new central model. Resave again as a new central model. -or- Incompatible servers for external services. -or- Username does not match the one used to create the local file. -or- Revit could not save all of the worksets that have been changed. Try again.|
|Autodesk.Revit.Exceptions FileAccessException||The file at the given path location could not be accessed or saved.|
|Autodesk.Revit.Exceptions FileNotFoundException||The given file, path or network location could not be found during save.|
|Autodesk.Revit.Exceptions ForbiddenForDynamicUpdateException||SaveAs may not be called during dynamic update.|
|Autodesk.Revit.Exceptions InsufficientResourcesException||This computer does not have enough memory, disk space, or other necessary resource to save the model.|
|Autodesk.Revit.Exceptions InvalidOperationException||This Document is not a primary document, it is a linked document. -or- SaveAs is temporarily disabled. -or- options.overwriteExistingFile is 'false' but there is an existing file at filepath. -or- options.overwriteExistingFile is 'true' but the target file at filepath is read only. -or- Saving is not allowed in the current application mode. -or- Operation is not permitted when there is any open sub-transaction, transaction, or transaction group. -or- Revit cannot clear the transmitted flag. This is not a transmitted document. -or- Saving failed.|
|Autodesk.Revit.Exceptions OperationCanceledException||Saving was canceled by the user or by an API event callback.|
|Autodesk.Revit.Exceptions OutdatedDirectlyOpenedCentralException||Other users have modified the central model while you had it opened. Resave your document as a local file and then synchronize with central again.|