AnalysisDisplayStyle Class


Exposes API for manipulation of analysis display style.

Namespace: Autodesk.Revit.DB.Analysis
Assembly: RevitAPI (in RevitAPI.dll) Version: 17.0.0.0 (17.0.484.0)
Since: 2011

Syntax

C#
public class AnalysisDisplayStyle : Element
Visual Basic
Public Class AnalysisDisplayStyle _
	Inherits Element
Visual C++
public ref class AnalysisDisplayStyle : public Element

Examples

Copy C#
Document doc = commandData.Application.ActiveUIDocument.Document;

AnalysisDisplayStyle analysisDisplayStyle = null;
// Look for an existing analysis display style with a specific name
FilteredElementCollector collector1 = new FilteredElementCollector(doc);
ICollection<Element> collection = collector1.OfClass(typeof(AnalysisDisplayStyle)).ToElements();
var displayStyle = from element in collection 
                   where element.Name == "Display Style 1" 
                   select element;

// If display style does not already exist in the document, create it
if (displayStyle.Count() == 0)
{
    AnalysisDisplayColoredSurfaceSettings coloredSurfaceSettings = 
        new AnalysisDisplayColoredSurfaceSettings();
    coloredSurfaceSettings.ShowGridLines = true;

    AnalysisDisplayColorSettings colorSettings = new AnalysisDisplayColorSettings();
    Color orange = new Color(255, 205, 0);
    Color purple = new Color(200, 0, 200);
    colorSettings.MaxColor = orange;
    colorSettings.MinColor = purple;

    AnalysisDisplayLegendSettings legendSettings = new AnalysisDisplayLegendSettings();
    legendSettings.NumberOfSteps = 10;
    legendSettings.Rounding = 0.05;
    legendSettings.ShowDataDescription = false;
    legendSettings.ShowLegend = true;

    analysisDisplayStyle = AnalysisDisplayStyle.CreateAnalysisDisplayStyle(doc, 
        "Display Style 1", coloredSurfaceSettings, colorSettings, legendSettings);
}
else
{
    analysisDisplayStyle = displayStyle.Cast<AnalysisDisplayStyle>().ElementAt<AnalysisDisplayStyle>(0);
}

// now assign the display style to the view
doc.ActiveView.AnalysisDisplayStyleId = analysisDisplayStyle.Id;
Copy VB.NET
Dim doc As Document = commandData.Application.ActiveUIDocument.Document

Dim analysisDisplayStyle__1 As AnalysisDisplayStyle = Nothing
' Look for an existing analysis display style with a specific name
Dim collector1 As New FilteredElementCollector(doc)
Dim collection As ICollection(Of Element) = collector1.OfClass(GetType(AnalysisDisplayStyle)).ToElements()
Dim displayStyle As System.Collections.Generic.IEnumerable(Of Autodesk.Revit.DB.Element)
displayStyle = From element In collector1 _
 Where element.Name = "Display Style 1" _
 Select element

' If display style does not already exist in the document, create it
If displayStyle.Count() = 0 Then
   Dim coloredSurfaceSettings As New AnalysisDisplayColoredSurfaceSettings()
   coloredSurfaceSettings.ShowGridLines = True

   Dim colorSettings As New AnalysisDisplayColorSettings()
   Dim orange As New Color(255, 205, 0)
   Dim purple As New Color(200, 0, 200)
   colorSettings.MaxColor = orange
   colorSettings.MinColor = purple

   Dim legendSettings As New AnalysisDisplayLegendSettings()
   legendSettings.NumberOfSteps = 10
   legendSettings.Rounding = 0.05
   legendSettings.ShowDataDescription = False
   legendSettings.ShowLegend = True

   analysisDisplayStyle__1 = AnalysisDisplayStyle.CreateAnalysisDisplayStyle(doc, "Display Style 1", coloredSurfaceSettings, colorSettings, legendSettings)
Else
   analysisDisplayStyle__1 = displayStyle.Cast(Of AnalysisDisplayStyle)().ElementAt(0)
End If

' now assign the display style to the view
doc.ActiveView.AnalysisDisplayStyleId = analysisDisplayStyle__1.Id

Inheritance Hierarchy

System Object
Autodesk.Revit.DB Element
Autodesk.Revit.DB.Analysis AnalysisDisplayStyle

See Also