Create Method (Document, Line)


Creates a new grid line.

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

Syntax

C#
public static Grid Create(
	Document document,
	Line line
)
Visual Basic
Public Shared Function Create ( _
	document As Document, _
	line As Line _
) As Grid
Visual C++
public:
static Grid^ Create(
	Document^ document, 
	Line^ line
)

Parameters

document
Type: Autodesk.Revit.DB Document
The document in which the new instance is created.
line
Type: Autodesk.Revit.DB Line
A line which represents the location of the grid line.

Return Value

The newly created grid line.

Remarks

The line should be on a horizontal plane.

Examples

Copy C#
// 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";
Copy VB.NET
   ' Create the geometry line which the grid locates
   Dim start As New XYZ(0, 0, 0)
   Dim [end] As New XYZ(30, 30, 0)
   Dim geomLine As Line = Line.CreateBound(start, [end])

   ' Create a grid using the geometry line
Dim lineGrid As Grid = Grid.Create(document, geomLine)

   If lineGrid Is Nothing Then
       Throw New Exception("Create a new straight grid failed.")
   End If

   ' Modify the name of the created grid
   lineGrid.Name = "New Name1"

Exceptions

Exception Condition
Autodesk.Revit.Exceptions ArgumentException document is not a project document. -or- The input line is not on horizontal plane.
Autodesk.Revit.Exceptions ArgumentNullException A non-optional argument was null

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 →