Creates a new instance of a GridSurface from a DEM file 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 CreateFromDEM(
	string DEMFileName,
	ObjectId styleId
)
Visual Basic
Public Shared Function CreateFromDEM ( _
	DEMFileName As String, _
	styleId As ObjectId _
) As ObjectId
Visual C++
public:
static ObjectId CreateFromDEM(
	String^ DEMFileName, 
	ObjectId styleId
)

Parameters

DEMFileName
Type: System..::..String
The path of the DEM file.
styleId
Type: ObjectId
The ObjectId of the SurfaceStyle for the GridSurface.

Examples

CopyC#
 1/// <summary>
 2/// Creates a new surface from a DEM file.
 3/// </summary>
 4/// <remarks></remarks>
 5[CommandMethod("CreateFromDEM")]
 6public void CreateFromDEM()
 7{
 8    using (Transaction ts = Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction())
 9    {
10        // Prompt user for a DEM file:
11        PromptFileNameResult demResult = editor.GetFileNameForOpen("Enter the path and name of the DEM file to import:");
12        editor.WriteMessage("Importing: {0}", demResult.StringResult);
13
14        try
15        {
16            // surface style #3 is "slope banding" in the default template
17            ObjectId surfaceStyleId = doc.Styles.SurfaceStyles[3];
18            ObjectId gridSurfaceId = GridSurface.CreateFromDEM(demResult.StringResult, surfaceStyleId);
19            editor.WriteMessage("Import succeeded: {0} \n", gridSurfaceId.ToString());
20        }
21        catch (System.Exception e)
22        {
23            // handle bad file data or other errors
24            editor.WriteMessage("Import failed: {0}", e.Message);
25        }
26
27        // commit the transaction
28        ts.Commit();
29    }
30}

Exceptions

ExceptionCondition
System..::..ArgumentException Thrown when:
  1. The DEMFileName is empty.
  2. The styleId is invalid or its type is not Autodesk.Civil.DatabaseServices.Styles.SurfaceStyle.
Autodesk.Civil..::..SurfaceException Thrown when the create operation fails.

See Also