RVTDocs.com
Namespace: Autodesk.Revit.DB

Grid

Class
Description:
Represents a single grid line within Autodesk Revit.
Remarks:
A Grid is a DatumPlane, so it is actually a three dimensional surface. It can be either a plane parallel to the project z-axis, or else a cylinder whose axis is parallel to the project z-xis. [!:Autodesk::Revit::DatumPlane]
Inheritance Hierarchy:
System.Object
  Autodesk.Revit.DB.Element
    Autodesk.Revit.DB.DatumPlane
      Autodesk.Revit.DB.Grid
Syntax
public class Grid : DatumPlane
Examples
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 + ")";
}