Share

DocumentPreviewSettings Class

Contains the settings related to the saving of preview images for a given document.

Inheritance Hierarchy

System.Object
  Autodesk.Revit.DB.DocumentPreviewSettings


Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 25.3.0.0 (25.3.0.0)

Syntax

C#

public class DocumentPreviewSettings : IDisposable

The DocumentPreviewSettings type exposes the following members.

Properties

 NameDescription
Public propertyIsValidObject Specifies whether the .NET object represents a valid Revit entity.
Public propertyIsViewUpdateForced Identifies if Revit will update the preview view if necessary.
Public propertyPreviewViewId The view id that will be used to generate the preview.

Methods

 NameDescription
Public methodDisposeReleases all resources used by the DocumentPreviewSettings
Public methodEqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Public methodForceViewUpdate Sets Revit to update the preview view if necessary.
Public methodGetHashCodeServes as the default hash function.
(Inherited from Object)
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Public methodIsViewIdValidForPreview Identifies if the view id is valid as a preview view id.
Public methodToStringReturns a string that represents the current object.
(Inherited from Object)

Example

C#

// 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();

VB

' Get the document's preview settings
Dim settings As DocumentPreviewSettings = document.GetDocumentPreviewSettings()

' Find a candidate 3D view
Dim collector As New FilteredElementCollector(document)
collector.OfClass(GetType(View3D))

Dim isValidForPreview As Func(Of View3D, Boolean) = Function(v) settings.IsViewIdValidForPreview(v.Id)

Dim viewForPreview As View3D = collector.OfType(Of View3D)().First(isValidForPreview)

' Set the preview settings
Using setTransaction As New Transaction(document, "Set preview view id")
    setTransaction.Start()
    settings.PreviewViewId = viewForPreview.Id
    setTransaction.Commit()
End Using

' Save the document
document.Save()

See Also

Reference

Was this information helpful?