Share

GridSurface.Create(String, Double, Double, Double, ObjectId) Method

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: 13.8.0.280

Syntax

C#

public static ObjectId Create(
	string surfaceName,
	double spacingX,
	double spacingY,
	double orientation,
	ObjectId styleId
)

VB

Public Shared Function Create ( 
	surfaceName As String,
	spacingX As Double,
	spacingY As Double,
	orientation As Double,
	styleId As ObjectId
) As ObjectId

C++

public:
static ObjectId Create(
	String^ surfaceName, 
	double spacingX, 
	double spacingY, 
	double orientation, 
	ObjectId styleId
)

Parameters

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

Return Value

ObjectId

Exceptions

ExceptionCondition
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.

Remarks

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

Example

 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}

See Also

Reference

Was this information helpful?