Creates a new instance of a GridSurface and adds it to the database that contains styleId.
Namespace: Autodesk.Civil.DatabaseServicesAssembly: AeccDbMgd (in AeccDbMgd.dll) Version: 13.4.2516.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
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
9
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
21 ObjectId surfaceId = GridSurface.Create(surfaceName, 25, 25, 0.0, surfaceStyleId);
22 GridSurface surface = surfaceId.GetObject(OpenMode.ForWrite) as GridSurface;
23
24
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
37 ts.Commit();
38 }
39}
Exceptions
Exception | Condition |
---|
System..::..ArgumentException |
Thrown when:
- The surfaceName is empty.
- The spacingX or spacingY are less than or equal to 0.0.
- The styleId is invalid or its type is not Autodesk.Civil.DatabaseServices.Styles.SurfaceStyle.
|
See Also