Grid |
Exception | Condition |
---|---|
ArgumentException |
Thrown when:
|
SurfaceException | Thrown when the create operation fails. |
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}