Dimension Class


An object that represents a dimension within the Revit project.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 2015.0.0.0 (2015.0.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 ((int)BuiltInCategory.OST_Dimensions == dimension.Category.Id.IntegerValue)
    {
        message += "\nDimension is a permanent dimension.";
    }
    else if ((int)BuiltInCategory.OST_Constraints == dimension.Category.Id.IntegerValue)
    {
        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 : " & Convert.ToString(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 : " & Convert.ToString(dimension.DimensionType.Name)

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

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

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


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

Inheritance Hierarchy

See Also

ArchiLabs Desktop

Put AI to work inside Revit.

Give Desktop your instructions and project files to build Revit families, update model elements, and create views and schedules. Works directly in Revit and AutoCAD.

Explore Desktop →