Civil 3D 中使用COM API导入DEM数据创建曲面
2013-01-29 11:24
453 查看
Civil 3D提供的基于.net的API和基于COM的API,现在推荐大家使用.net API,但有时也需要使用COM API。 这个例子演示如何使用COM API来导入DEM数据生成Civil 3D曲面。 Civil 3D开发中使用COM API需要添加的引用比较啰嗦,建议使用向导创建项目简化操作,向导能帮助你添加大部分引用,如果还缺什么,自己再添加就简单多了。注意使用COM API,需要勾选AutoCAD 和Civil 3D的interOp相关引用。
下面是使用COM API导入DEM数据的代码:
下面是使用COM API导入DEM数据的代码:
// (C) Copyright 2013 by Autodesk // using System; using Autodesk.AutoCAD.Runtime; using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.Geometry; using Autodesk.AutoCAD.EditorInput; using System.Windows.Forms; using Autodesk.AECC.Interop.UiLand; using Autodesk.AutoCAD.Interop; using Autodesk.Civil.ApplicationServices; // This line is not mandatory, but improves loading performances [assembly: CommandClass(typeof(LoadDEM_demo.MyCommands))] namespace LoadDEM_demo { public class MyCommands { // COM objects: private Autodesk.AutoCAD.Interop.IAcadApplication m_oAcadApp = null; private Autodesk.AECC.Interop.UiLand.IAeccApplication m_oAeccApp = null; private Autodesk.AECC.Interop.UiLand.IAeccDocument m_oAeccDoc = null; private Autodesk.AECC.Interop.Land.IAeccDatabase m_oAeccDb = null; string m_sAcadProdID = "AutoCAD.Application"; string m_sAeccAppProgId = "AeccXUiLand.AeccApplication.10.0"; //Civil 3D 2013 //string m_sAeccAppProgId = "AeccXUiLand.AeccApplication.9.0"; //Civil 3D 2012 private string m_sMessage = ""; [CommandMethod("LoadDemSurfaceop")] public void LoadDemSurface() { try { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "USGS DEM( *.DEM) |*.dem|GEOTIFF(*.tif)|*.tif|ESRI ASCII 栅格(*.asc)|*.asc|ESRI ASCII 栅格(*.txt)|*.txt|ESRI 二进制栅格(*.adf)|*.adf"; ofd.FilterIndex = 0; if (ofd.ShowDialog() == DialogResult.OK) { //use COM m_oAcadApp = (IAcadApplication)System.Runtime.InteropServices.Marshal.GetActiveObject(m_sAcadProdID); if (m_oAcadApp != null) { m_oAeccApp = (IAeccApplication)m_oAcadApp.GetInterfaceObject(m_sAeccAppProgId); m_oAeccDoc = (IAeccDocument)m_oAeccApp.ActiveDocument; m_oAeccDoc.Surfaces.ImportDEM(ofd.FileName); } m_oAeccDoc.Regen(Autodesk.AutoCAD.Interop.Common.AcRegenType.acActiveViewport); } else { } } catch (System.Exception e) { MessageBox.Show(e.Message); } finally { } } } }
相关文章推荐
- 使用navicat8实现创建数据库和导入数据[图文]
- 使用OpenXml操作Excel,创建excel,导入DataTable的数据等
- Oracle sqldevelop的使用(数据即.dmp文件的导入,用户创建,创建连接)
- 使用navicat8实现创建数据库和导入数据[图文]
- HIVE的安装配置、mysql的安装、hive创建表、创建分区、修改表等内容、hive beeline使用、HIVE的四种数据导入方式、使用Java代码执行hive的sql命令
- Imode平台下使用原生数据创建3D模型_旋转
- 创建hive表和使用Load data指令导入数据的注意事项
- mysql创建数据库,创建数据库表导入xlsx、txt文本,查询、删除、插入数据语句的使用
- mysql导入导出数据中文乱码解决方法小结(1、navicat导入问题已解决,创建连接后修改连接属性,选择高级->将使用Mysql字符集复选框去掉,下拉框选择GBK->导入sql文件OK;2、phpmyadmin显示乱码的问题也解决,两步:1.将sql文件以utf8的字符集编码另存,2.将文件中sql语句中的字段字符集编码改成utf8,导入OK)
- 使用navicat 8实现创建数据库和导入数据 管理用户与权限[图文方法]
- 使用 Solr 创建 Core 并导入数据库数据
- 使用navicat 8实现创建数据库和导入数据 管理用户与权限[图文方法]
- unity 3d中如何创建公有共用的代码段或数据,让所有其他类或者脚本都能访问?(代码说明static 静态类的使用)
- 【步步为营 Entity Framework+Reporting service开发】-(3) 创建commandline 应用程序 ,使用EF导入数据
- 使用Talend Open Studio将数据分步从oracle导入到hive中
- 使用BCP导入导出数据
- [置顶] 【Solr】深入浅出Solr(三)——使用Solrj向索引库中导入数据
- SQL Server 2008空间数据应用系列九:使用空间工具(Spatial Tools)导入ESRI格式地图数据
- 使用数据泵expdp命令和impdp命令对数据库的数据进行导入导出