AutoCAD Civil 3D Help: Creating a Grid Surface from a DEM File

从一个DEM文件创建一个网格曲面


你可以用GridSurface.CreateFromDEM() 方法从一个Digital Elevation Model (DEM) 文件创建一个网格曲面。该方法有2个重载方法:一个采用缺省样式,另外一个允许你指定曲面样式。两者都采用string来读取DEM文件名及其路径。

[CommandMethod("CreateFromDEM")]
public void CreateFromDEM()
{
    using (Transaction ts = Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction())
    {
        // Prompt user for a DEM file:
        // string demFile = @"C:\Program Files\Autodesk\AutoCAD Civil 3D 2013\Help\Civil Tutorials\Corridor surface.tin";
        PromptFileNameResult demResult = editor.GetFileNameForOpen("Enter the path and name of the DEM file to import:");
        editor.WriteMessage("Importing: {0}", demResult.StringResult);

        try
        {
            // surface style #3 is "slope banding" in the default template
            ObjectId surfaceStyleId = doc.Styles.SurfaceStyles[3];
            ObjectId gridSurfaceId = GridSurface.CreateFromDEM(demResult.StringResult, surfaceStyleId);
            editor.WriteMessage("Import succeeded: {0} \n", gridSurfaceId.ToString());
        }
        catch (System.Exception e)
        {
            // handle bad file data or other errors
            editor.WriteMessage("Import failed: {0}", e.Message);
        }

        // commit the transaction
        ts.Commit();
    }
}

父主题:

创建曲面

results matching ""

    No results matching ""