GraphicsStyleId Property


The ElementId of the GeometryObject's GraphicsStyle

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

Syntax

C#
public ElementId GraphicsStyleId { get; }
Visual Basic
Public ReadOnly Property GraphicsStyleId As ElementId
	Get
Visual C++
public:
property ElementId^ GraphicsStyleId {
	ElementId^ get ();
}

Remarks

This property provides the id of the GraphicsStyle assigned to the GeometryObject. This can be used to find the category of the object.

Examples

Copy C#
// find the name of the GraphicsSytleCategory for every geometric primitive in a family instance
        Options options = app.Create.NewGeometryOptions();
        GeometryElement geomElem = element.get_Geometry(options);
        foreach (GeometryObject geomObj in geomElem)
        {
            GeometryInstance geomInst = geomObj as GeometryInstance;
            if (geomInst != null)
            {
                foreach (Object obj in geomInst.SymbolGeometry)
                {
                    GeometryObject geomObject = obj as GeometryObject;
                    GraphicsStyle gStyle = doc.GetElement(geomObject.GraphicsStyleId) as GraphicsStyle;
                    if (gStyle != null)
                    {
                        string gstyleName = gStyle.GraphicsStyleCategory.Name;
                    }
                }
            }
        }
Copy VB.NET
' find the name of the GraphicsSytleCategory for every geometric primitive in a family instance
Dim options As Options = app.Create.NewGeometryOptions()
Dim geomElem As GeometryElement = element.Geometry(options)
For Each geomObj As GeometryObject In geomElem
    Dim geomInst As GeometryInstance = TryCast(geomObj, GeometryInstance)
    If geomInst IsNot Nothing Then
        For Each obj As [Object] In geomInst.SymbolGeometry
            Dim geomObject As GeometryObject = TryCast(obj, GeometryObject)
            Dim gStyle As GraphicsStyle = TryCast(doc.GetElement(geomObject.GraphicsStyleId), GraphicsStyle)
            If gStyle IsNot Nothing Then
                Dim gstyleName As String = gStyle.GraphicsStyleCategory.Name
            End If
        Next
    End If

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 →