Creates a new instance of a GridSurface and adds it to the database that contains styleId.

Namespace: Autodesk.Civil.DatabaseServices
Assembly: AeccDbMgd (in AeccDbMgd.dll) Version: 10.3.488.0

Syntax

C#
public static ObjectId Create(
	string surfaceName,
	double spacingX,
	double spacingY,
	double orientation,
	ObjectId styleId
)
Visual Basic
Public Shared Function Create ( _
	surfaceName As String, _
	spacingX As Double, _
	spacingY As Double, _
	orientation As Double, _
	styleId As ObjectId _
) As ObjectId
Visual C++
public:
static ObjectId Create(
	String^ surfaceName, 
	double spacingX, 
	double spacingY, 
	double orientation, 
	ObjectId styleId
)

Parameters

surfaceName
Type: System..::..String
The name of the new GridSurface.
spacingX
Type: System..::..Double
The x spacing of the GridSurface.
spacingY
Type: System..::..Double
The y spacing of the GridSurface.
orientation
Type: System..::..Double
The orientation of the GridSurface.
styleId
Type: ObjectId
The ObjectId of the style to apply to the GridSurface.

Remarks

The units for spacingX, spacingY and orientation are taken from the settings in SettingsCmdCreateSurface.

Examples

CopyC#
 1[CommandMethod("CreateGridSurface")]
 2public void CreateGridSurface()
 3{
 4    using (Transaction ts = Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction())
 5    {
 6        string surfaceName = "ExGridSurface";
 7
 8        // Select a surface style to use.
 9        // If the desired style doesn't exist, create it.
10        ObjectId surfaceStyleId = ObjectId.Null;
11        try
12        {
13            surfaceStyleId = doc.Styles.SurfaceStyles["Slope Banding (2D)"];
14        }
15        catch (System.ArgumentException e)
16        {
17            surfaceStyleId = doc.Styles.SurfaceStyles.Add("Slope Banding (2D)");
18        }
19
20        // Create the surface with grid spacing of 25' x 25', orientation 0 degrees:
21        ObjectId surfaceId = GridSurface.Create(surfaceName, 25, 25, 0.0, surfaceStyleId);
22        GridSurface surface = surfaceId.GetObject(OpenMode.ForWrite) as GridSurface;
23
24        // Add some random points
25        Random m_Generator = new Random();
26        for (int i = 0; i < 10; i++)
27        {
28            for (int j = 0; j < 10; j++)
29            {
30                double z = m_Generator.NextDouble() * 10;
31                GridLocation loc = new GridLocation(i, j);
32                surface.AddPoint(loc, z);
33            }
34        }
35
36        // commit the create action
37        ts.Commit();
38    }
39}

Exceptions

ExceptionCondition
System..::..ArgumentException Thrown when:
  1. The surfaceName is empty.
  2. The spacingX or spacingY are less than or equal to 0.0.
  3. The styleId is invalid or its type is not Autodesk.Civil.DatabaseServices.Styles.SurfaceStyle.

See Also