RVTDocs.com
Namespace: Autodesk.Revit.DB Class: Grid

Grid.Create(Document, Line)

Method
Description:
Creates a new grid line.
Remarks:
The line should be on a horizontal plane.
Syntax
public static Grid Create(
	Document document,
	Line line
)
Examples
// Create the geometry line which the grid locates
 XYZ start = new XYZ(0, 0, 0);
 XYZ end = new XYZ(30, 30, 0);
 Line geomLine = Line.CreateBound(start, end);

 // Create a grid using the geometry line
 Grid lineGrid = Grid.Create(document, geomLine);

 if (null == lineGrid)
 {
     throw new Exception("Create a new straight grid failed.");
 }

 // Modify the name of the created grid
 lineGrid.Name = "New Name1";
Parameters
Parameter Type Description
document Document The document in which the new instance is created.
line Line A line which represents the location of the grid line.
Return Value
Type Description
Grid The newly created grid line.
Exceptions
Exception Condition
ArgumentException document is not a project document. -or- The input line is not on horizontal plane.
ArgumentNullException A non-optional argument was null