RenderingSettings Class


Represents the rendering settings for a 3d view.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 2015.0.0.0 (2015.0.0.0)
Since: 2013

Syntax

C#
public class RenderingSettings : IDisposable
Visual Basic
Public Class RenderingSettings _
	Implements IDisposable
Visual C++
public ref class RenderingSettings : IDisposable

Examples

Copy C#
public void GetRenderingSettingsData(View3D view3D)
{
    RenderingSettings renderingSettings = view3D.GetRenderingSettings();

    // get print or screen resolution data
    if (renderingSettings.ResolutionTarget == ResolutionTarget.Printer) // for print resolution
    {
        PrinterResolution printResolution = renderingSettings.PrinterResolution;
        int resolutionValue = renderingSettings.ResolutionValue;
    }
    else    // for screen resolution
    {
        int resolutionValue = renderingSettings.ResolutionValue;
    }

    // Get the outline of the rendering region. 
    renderingSettings.UsesRegionRendering = true;
    Outline regionOutline = renderingSettings.GetRenderingRegionOutline();
    XYZ max = regionOutline.MaximumPoint;
    XYZ min = regionOutline.MinimumPoint;

    // get lighting information.
    renderingSettings.LightingSource = LightingSource.ExteriorSun; // set lighting scheme type
    // Please note that the sun setting has been exposed in View.SunAndShadowSettings property already.
    SunAndShadowSettings sunSettings = view3D.SunAndShadowSettings;

    // get the background setting data
    switch (renderingSettings.BackgroundStyle)
    {
        case BackgroundStyle.Color: // for color style
            ColorBackgroundSettings colorBKSettings = renderingSettings.GetBackgroundSettings() as ColorBackgroundSettings;
            Color bkColor = colorBKSettings.Color;
            break;
        case BackgroundStyle.Image: // for image style
            ImageBackgroundSettings imageBKSettings = renderingSettings.GetBackgroundSettings() as ImageBackgroundSettings;
            BackgroundImageFit imageFit = imageBKSettings.BackgroundImageFit;
            string filePath = imageBKSettings.FilePath;
            break;
        case BackgroundStyle.SkyCloudy: // for sky related styles
        case BackgroundStyle.SkyFewClouds:
        case BackgroundStyle.SkyNoClouds:
        case BackgroundStyle.SkyVeryCloudy:
        case BackgroundStyle.SkyVeryFewClouds:
            SkyBackgroundSettings skyBKSettings = renderingSettings.GetBackgroundSettings() as SkyBackgroundSettings;
            float visibilityDis = skyBKSettings.VisibilityDistance;
            break;
        default:
            throw new InvalidOperationException("Not expected background style");
    }

    // Get the rendering image exposure settings
    RenderingImageExposureSettings exposureSettings = renderingSettings.GetRenderingImageExposureSettings();
    double imageShadows = exposureSettings.Shadows;

    // Get the rendering quality settings
    RenderingQualitySettings qualitySettings = renderingSettings.GetRenderingQualitySettings();
    RenderingQuality qualitySytle = qualitySettings.RenderingQuality;   // get rendering quality enum
    if(qualitySytle == RenderingQuality.Custom)
    {
        // The user can set the data only in custom quality
        qualitySettings.ImagePrecision = 1;
    }
    else
    {
        // Different property value is retruned according to its rendering quality style.
        // Take ImagePrecision property for example, it returns 1 for Draft quality and returns 2 for low quality.
        int imagePrecision = qualitySettings.ImagePrecision;
    }
}
Copy VB.NET
Public Sub GetRenderingSettingsData(view3D As View3D)
    Dim renderingSettings As RenderingSettings = view3D.GetRenderingSettings()

    ' get print or screen resolution data
    If renderingSettings.ResolutionTarget = ResolutionTarget.Printer Then
        ' for print resolution
        Dim printResolution As PrinterResolution = renderingSettings.PrinterResolution
        Dim resolutionValue As Integer = renderingSettings.ResolutionValue
    Else
        ' for screen resolution
        Dim resolutionValue As Integer = renderingSettings.ResolutionValue
    End If

    ' Get the outline of the rendering region. 
    renderingSettings.UsesRegionRendering = True
    Dim regionOutline As Outline = renderingSettings.GetRenderingRegionOutline()
    Dim max As XYZ = regionOutline.MaximumPoint
    Dim min As XYZ = regionOutline.MinimumPoint

    ' get lighting information.
    renderingSettings.LightingSource = LightingSource.ExteriorSun
    ' set lighting scheme type
    ' Please note that the sun setting has been exposed in View.SunAndShadowSettings property already.
    Dim sunSettings As SunAndShadowSettings = view3D.SunAndShadowSettings

    ' get the background setting data
    Select Case renderingSettings.BackgroundStyle
        Case BackgroundStyle.Color
            ' for color style
            Dim colorBKSettings As ColorBackgroundSettings = TryCast(renderingSettings.GetBackgroundSettings(), ColorBackgroundSettings)
            Dim bkColor As Color = colorBKSettings.Color
            Exit Select
        Case BackgroundStyle.Image
            ' for image style
            Dim imageBKSettings As ImageBackgroundSettings = TryCast(renderingSettings.GetBackgroundSettings(), ImageBackgroundSettings)
            Dim imageFit As BackgroundImageFit = imageBKSettings.BackgroundImageFit
            Dim filePath As String = imageBKSettings.FilePath
            Exit Select
            ' for sky related styles
        Case BackgroundStyle.SkyCloudy, BackgroundStyle.SkyFewClouds, BackgroundStyle.SkyNoClouds, BackgroundStyle.SkyVeryCloudy, BackgroundStyle.SkyVeryFewClouds
            Dim skyBKSettings As SkyBackgroundSettings = TryCast(renderingSettings.GetBackgroundSettings(), SkyBackgroundSettings)
            Dim visibilityDis As Single = skyBKSettings.VisibilityDistance
            Exit Select
        Case Else
            Throw New InvalidOperationException("Not expected background style")
    End Select

    ' Get the rendering image exposure settings
    Dim exposureSettings As RenderingImageExposureSettings = renderingSettings.GetRenderingImageExposureSettings()
    Dim imageShadows As Double = exposureSettings.[Shadows]

    ' Get the rendering quality settings
    Dim qualitySettings As RenderingQualitySettings = renderingSettings.GetRenderingQualitySettings()
    Dim qualitySytle As RenderingQuality = qualitySettings.RenderingQuality
    ' get rendering quality enum
    If qualitySytle = RenderingQuality.[Custom] Then
        ' The user can set the data only in custom quality
        qualitySettings.ImagePrecision = 1
    Else
        ' Different property value is retruned according to its rendering quality style.
        ' Take ImagePrecision property for example, it returns 1 for Draft quality and returns 2 for low quality.
        Dim imagePrecision As Integer = qualitySettings.ImagePrecision
    End If
End Sub

Inheritance Hierarchy

System Object
Autodesk.Revit.DB RenderingSettings

See Also

ArchiLabs

Stop fighting Revit automation.

Build repeatable BIM design and documentation workflows with scripts, data, and AI in one place, without wrestling brittle one-off automations.

Try ArchiLabs →