2024 Method
Changes 0
M

View3D.GetRenderingSettings

Description:
Returns the current rendering settings for this 3d view.
public RenderingSettings GetRenderingSettings()
RenderingSettings The returned object represents the current rendering settings. If you change the returned object, you need to call SetRenderingSettings to apply the new settings back to Revit.
public RenderingSettings GetFirstRenderingSettings(Document document)
{
    // RenderingSettings isn't used to support family document.
    if (document.IsFamilyDocument)
        return null;

    // Get 3d view
    List<View3D> theView3Ds = new List<View3D>();
    foreach (View3D view3D in RetrieveElementByType<View3D>(document))
    {
        // It's strongly recommend to get  RenderingSettings from visible 3d view, 
        // although it can retrieve data from an invisible one,
        if (view3D.IsTemplate || !view3D.CanBePrinted)
            continue;
        return view3D.GetRenderingSettings();
    }
    return null;
}

public static List<T> RetrieveElementByType<T>(Document document) where T : Autodesk.Revit.DB.Element
{
    FilteredElementCollector collector = new FilteredElementCollector(document);
    return collector.OfClass(typeof(T)).Cast<T>().ToList<T>();
}