Dimension Class


An object that represents a dimension within the Revit project.

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

Syntax

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

Examples

Copy C#
public void GetInfo_Dimension(Dimension dimension)
{
    string message = "Dimension : ";
    // Get Dimension name
    message += "\nDimension name is : " + dimension.Name;

    // Get Dimension Curve
    Autodesk.Revit.DB.Curve curve = dimension.Curve;
    if (curve != null && curve.IsBound)
    {
        // Get curve start point
        message += "\nCurve start point:(" + curve.GetEndPoint(0).X + ", "
             + curve.GetEndPoint(0).Y + ", " + curve.GetEndPoint(0).Z + ")";
        // Get curve end point
        message += "; Curve end point:(" + curve.GetEndPoint(1).X + ", "
             + curve.GetEndPoint(1).Y + ", " + curve.GetEndPoint(1).Z + ")";
    }

    // Get Dimension type name
    message += "\nDimension type name is : " + dimension.DimensionType.Name;

    // Get Dimension view name
    message += "\nDimension view name is : " + dimension.View.Name;

    // Get Dimension reference count
    message += "\nDimension references count is " + dimension.References.Size;

    if (BuiltInCategory.OST_Dimensions == dimension.Category.BuiltInCategory)
    {
        message += "\nDimension is a permanent dimension.";
    }
    else if (BuiltInCategory.OST_Constraints == dimension.Category.BuiltInCategory)
    {
        message += "\nDimension is a constraint element.";
    }


    TaskDialog.Show("Revit",message);
}
Copy VB.NET
Public Sub GetInfo_Dimension(dimension As Dimension)
   Dim message As String = "Dimension : "
   ' Get Dimension name
   message += vbLf & "Dimension name is : " + dimension.Name

   ' Get Dimension Curve
   Dim curve As Autodesk.Revit.DB.Curve = dimension.Curve
   If curve IsNot Nothing AndAlso curve.IsBound Then
      ' Get curve start point
      message += vbLf & "Curve start point:(" + curve.GetEndPoint(0).X + ", " + curve.GetEndPoint(0).Y + ", " + curve.GetEndPoint(0).Z + ")"
      ' Get curve end point
      message += "; Curve end point:(" + curve.GetEndPoint(1).X + ", " + curve.GetEndPoint(1).Y + ", " + curve.GetEndPoint(1).Z + ")"
   End If

   ' Get Dimension type name
   message += vbLf & "Dimension type name is : " + dimension.DimensionType.Name

   ' Get Dimension view name
   message += vbLf & "Dimension view name is : " + dimension.View.Name

   ' Get Dimension reference count
   message += vbLf & "Dimension references count is " + dimension.References.Size

   If BuiltInCategory.OST_Dimensions = dimension.Category.BuiltInCategory Then
      message += vbLf & "Dimension is a permanent dimension."
   ElseIf BuiltInCategory.OST_Constraints = dimension.Category.BuiltInCategory Then
      message += vbLf & "Dimension is a constraint element."
   End If


   TaskDialog.Show("Revit", message)
End Sub

Inheritance Hierarchy

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 →