Grid Class


Represents a single grid line within Autodesk Revit.

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

Syntax

C#
public class Grid : DatumPlane
Visual Basic
Public Class Grid _
	Inherits DatumPlane
Visual C++
public ref class Grid : public DatumPlane

Remarks

Grid lines can either be curved or straight. The Name property can be used to retrieve the contents of the grid line's bubble.

Examples

Copy C#
public void GetInfo_Grid(Grid grid)
{
    string message = "Grid : ";

    // Show IsCurved property
    message += "\nIf grid is Arc : " + grid.IsCurved;

    // Show Curve information
    Autodesk.Revit.DB.Curve curve = grid.Curve;
    if (grid.IsCurved)
    {
        // if the curve is an arc, give center and radius information
        Autodesk.Revit.DB.Arc arc = curve as Autodesk.Revit.DB.Arc;
        message += "\nArc's radius: " + arc.Radius;
        message += "\nArc's center:  (" + XYZToString(arc.Center);
    }
    else
    {
        // if the curve is a line, give length information
        Autodesk.Revit.DB.Line line = curve as Autodesk.Revit.DB.Line;
        message += "\nLine's Length: " + line.Length;
    }
    // Get curve start point
    message += "\nStart point: " + XYZToString(curve.GetEndPoint(0));
    // Get curve end point
    message += "; End point: " + XYZToString(curve.GetEndPoint(0));

    TaskDialog.Show("Revit",message);
}

// output the point's three coordinates
string XYZToString(XYZ point)
{
    return "(" + point.X + ", " + point.Y + ", " + point.Z + ")";
}
Copy VB.NET
Public Sub GetInfo_Grid(grid As Grid)
    Dim message As String = "Grid : "

    ' Show IsCurved property
    message += vbLf & "If grid is Arc : " & Convert.ToString(grid.IsCurved)

    ' Show Curve information
    Dim curve As Autodesk.Revit.DB.Curve = grid.Curve
    If grid.IsCurved Then
        ' if the curve is an arc, give center and radius information
        Dim arc As Autodesk.Revit.DB.Arc = TryCast(curve, Autodesk.Revit.DB.Arc)
        message += vbLf & "Arc's radius: " + arc.Radius
        message += vbLf & "Arc's center:  (" & XYZToString(arc.Center)
    Else
        ' if the curve is a line, give length information
        Dim line As Autodesk.Revit.DB.Line = TryCast(curve, Autodesk.Revit.DB.Line)
        message += vbLf & "Line's Length: " + line.Length
    End If
    ' Get curve start point
    message += vbLf & "Start point: " & XYZToString(curve.GetEndPoint(0))
    ' Get curve end point
    message += "; End point: " & XYZToString(curve.GetEndPoint(0))

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

' output the point's three coordinates
Private Function XYZToString(point As XYZ) As String
    Return "(" & Convert.ToString(point.X) & ", " & Convert.ToString(point.Y) & ", " & Convert.ToString(point.Z) & ")"
End Function

Inheritance Hierarchy

See Also