DocumentPreviewSettings Class
Contains the settings related to the saving of preview images for a given document.
// Get the document's preview settings
DocumentPreviewSettings settings = document.GetDocumentPreviewSettings();
// Find a candidate 3D view
FilteredElementCollector collector = new FilteredElementCollector(document);
collector.OfClass(typeof(View3D));
Func<View3D, bool> isValidForPreview = v => settings.IsViewIdValidForPreview(v.Id);
View3D viewForPreview = collector.OfType<View3D>().First<View3D>(isValidForPreview);
// Set the preview settings
using (Transaction setTransaction = new Transaction(document, "Set preview view id"))
{
setTransaction.Start();
settings.PreviewViewId = viewForPreview.Id;
setTransaction.Commit();
}
// Save the document
document.Save();