GridSurfaceCreate(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.DatabaseServicesAssembly: AeccDbMgd (in AeccDbMgd.dll) Version: 13.8.0.292
Syntaxpublic static ObjectId Create(
string surfaceName,
double spacingX,
double spacingY,
double orientation,
ObjectId styleId
)
Public Shared Function Create (
surfaceName As String,
spacingX As Double,
spacingY As Double,
orientation As Double,
styleId As ObjectId
) As ObjectId
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
ExceptionsException | Condition |
---|
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.
|
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
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}
See Also