



免费预览已结束,剩余1页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
第 10 卷第 5 期Vol. 10, No. 5GEOSPATIALINFORMATION基于 CAD 的 VisualLISP 二次开发在农村土地现状调查中的应用林志鹏,余代俊(成都理工大学 地球科学学院,四川 成都 610059)摘 要:为加速 CAD 二次开发而提供的 VisualLISP 语言是嵌入在 AutoCAD 内部的计算机编程语言。以几个具体的实例说明在农村土地现状调查中利用 VisualLISP 程序设计能提高作业效率,减少劳动力,灵活高效。关键词:VisualLISP;AutoCAD;程序设计;土地调查中图分类号:P258文献标志码: B文章编号: 1672-4623 (2012) 05-0153-04随着现代科学技术的不断发展,AutoCAD 已在各行业得到了极其广泛的应用。但是,由于 AutoCAD 涉 及范围较大,深层次运用针对性不足,使其不能满足 许多行业在深层次运用中的功能需求。因此,CAD 二 次开发技术的推广也就成为眼下迫切需要解决的问题。 AutoCAD 公司为此相继向用户推出了各种开发工具: ADS、VisualLISP、VBA 和 ObjectARX 1。然而,每种 开发工具都有各自的优缺点,各行业的开发者应视具体 情况而选取。为方便 CAD 在农村土地现状调查中的应 用,笔者采用 VisualLISP 作为二次开发工具,以具体的 程序代码和实例说明其在该领域的确起到了极大的作用。的范围不仅包括农村集体建设用地还包括农户个体用地,后者需落实到具体的户。在进行土地承包经营权 权属调查中,依据外调人员所划分的实际各户承包地 面积和所提供的影像图资料进行承包地绘制、分割、调 整、检查承包地面积及地块面积属性统计与导出等一 系列工作时,产生了诸多问题。如:图形数据不规范(内业勾绘的田块图及斑权属界线重复或未闭合,相邻 图斑和界线间出现交叉、缝隙等),属性数据与图形数 据未匹配(地块编号漏号、重号或与权力人未对应,地类符号与实际地类不匹配等)。由于此类问题的存在,无法建立相关 GIS 数据库,但若完全依靠人工干预解决这些问题,势必效率低下且易造成遗漏 4。因此,利 用 VisualLISP 语言在 CAD 下进行编程,进行某些自动 化处理,极大地方便了内业作业人员成图,提高了工 作效率。对此,笔者着重讨论了 CAD 图形中的相关数1VisualLISP 语言VisualLISP 语言是内嵌于 AutoCAD,建立在 Auto-LISP 基础上的软件开发工具。它具有独立的集成开发 环境,包括文本编辑器、语法检查器、源代码调试器 及智能化的控制台等,用户利用它可以随意地编辑、编 译、修改及调试 AutoLISP 源程序,通过编译得到运行 效率高,代码紧凑,源代码受保护的应用程序 2。在功能方面,从 AutoCAD R14 开始,VisuaLISP 被 引入到 AutoCAD 中,继承了 AutoLISP 所有的优点,并 对其功能进行了扩展,用户可通过 Microsoft ActiveX Automation 接口与 AutoCAD 对象进行交互,访问 Auto- CAD 的多文档设计环境,利用反应器函数扩展AutoLISP 相应事件的能力 3。据及属性与Excel 交互操作在具体的工程实例中的应用。2.2应用实例在测绘行业领域中,基于 CAD 的二次开发南 方 CASS 数字化成图软件,虽向测绘人员提供了许多 辅助该行业数字化成图的工具,但其在对某些具体需 求的图形操作、地物检查、与外部应用程序交互等方 面,仍存在较多问题都还有待作业人员自己解决,由 此列举几个具体的应用实例供相关人员参考。2.2.1CAD 图形操作1 ) 图形绘制。由于在绘图过程中存在多种属性的 图层,如地块编号、地类类型、村、组界等,在绘图 过程中,对图层的操作和修改必须通过 CAD 的图层管 理器,这样的操作势必给内业人员来带不便,因此有 必要编制与图层控制相关的绘图程序以达到一键控制 的快速操作,从而提高作业效率。因此,可直接通过2VisualLISP 语言在土地现状调查中的应用2.1解决问题近两年,农村产权制度改革在某些城市得到推行。 该方案包括了权属调查和土地利用现状的调查,调查收稿日期:2011-10-17(Defun c: tk()者相同,再求出两图元之间的距离,如果其值在一定范围之内,则说明它们相互重合,便将当前图元标识 出来存放于独立的“重复块”图层之中,同时将该图 元从选择集中删除,部分代码如下:(setq sslen (sslength ss); 提取图元个数 (setq n 0 value (- len 0.5); 设置图元间隔 (while ( i sslen); 遍历选择集中的实体(setq en (ssname ss i)(command osmode 2049) ;设置对象捕捉类型(command -LAYER m 田坎 c 3 ) ;新 建田坎的图层(command LAYERDEFPOINTS )SET 田坎 on 0 on (setvar CLAYER 田坎);将田坎层设为当前层(setvar CECOLOR Bylayer);颜色随层(command pline) (princ)2 ) 快速标注。依据相关内业成图规范,事先设定 各地块的注记字体类型、高度、颜色及线型,快速对 地物属性进行标注。例如,快速标注林盘的代码如下:(setq entype (cdr assoc 0 en); 判断图元类型,为标记文字还是地块类型(setq jb (assoc 5 list2); 提取图元句柄(if jb(setq list2 (subst (5 . cfk) jb list2)(Defun c: lp()(command _layer m 林盘 c 2 );盘的图层,颜色为黄色新建一林)(alert (strcat 共检查地块,重复地块!)最后,在此基础上将该程序与 DCL 相整合,运行 时的程序功能对话框如图 1 所示。(command _layer set 林盘前层(setvar CECOLOR Bylayer);将该图层设为当(setvar CELTYPE Continuous)(while (setq pt (getpoint n 请选定注记位置: (command . _text S 宋体 pt 4 0 林盘)3) 地块检查。为满足 GIS 建库中拓扑重建等相关要求,所有地块数目和与之相对应的地块编号数应相 等,所有地块图形也必须为连续线型的封闭区域。但 在实际生产成图过程中,由于作业人员的疏忽或作业 的不规范,达到上述作业标准存在一定的困难,可见 地物图形的检查在整个成图过程中占据着相当重要的 地位 5。若完全依靠人工干预对整图地块图斑检查又 需耗费大量劳动力,因此有必要编写一个地块图形检 查程序对地块图斑的重复线、相交线及封闭性进行检查。为避免赘述,这里仅以地块检查程序为例,说明 其实现自动查找统计地块数、地块编号数及重复地块 数的功能。该实例中,由于地物实体类型较多 (如地 块线、文字注记),因此需使用选择集的过滤功能将所 需检查的实体类型提取出来做特定的处理:(setq ss (ssget X (-4 . AND) (-4 . ) (-4. AND)图 1 地块图形检查界面程序运行后,检查出重复地块,并将其以黄色标 注,其实现的功能效果如图 2 所示。图 2 重复地块检查第 10 卷第 5 期林志鹏等:基于 CAD 的 VisualLISP 二次开发在农村土地现状调查中的应用1552.2.2 CAD 图形与 Excel 交互操作测量工作中,常常会遇到 CAD 图形数据与 Excel 交互通信的操作,如专业成图软件(南方 CASS 等)将 坐标数据展绘于 CAD 图形中时,必须将测量坐标数据 保存于 TXT 或 DAT 文件。而在测量工作中,坐标数据 通常保存于 Excel 中,若想实现坐标展绘,则需先将 Excel 中的坐标数据复制于 TXT 或 DAT 文件中,同时 还需设定更改坐标数据之间的分隔符,操作起来略显 繁琐。因此,笔者在该应用实例中编写了将 Excel 中界 址点坐标数据直接展绘于 CAD 图形、提取地块面积等 属性至 Excel 表格等程序,以避免给成图过程带来各种 繁琐的操作。1)将 Excel 界址点坐标数据展绘于 CAD 图形中。 由于 Application 对象是 AutoCAD ActiveX Automation 对象模型的 Root 对象,换言之,AutoCAD、Excel、 Word 等应用程序本身也是对象,因此,可利用VisualLISP 控制访问 ActiveX 对象6。图 3 为设计程序的简要流程。MX-); 创建并显示 Excel 应用程序对象(setq XLobj (vlax-create-object Excel. Applica-tion)(vla-put-visible XLobj 1); 打开文件并创建工作簿(vlax-invoke-method (vlax-get-property XLobj WorkBooks) Open filename); 创建工作表对象(setq sheetobj (MX-get-activesheet XLobj); 函数调用,获取坐标数据(setq all_list_data (get-xl-data sheetobj); 函数调 用,获取坐标数据(import_point)在对 Excel 对象操作,读取其中的坐标数据时,需 确定 Excel 文件坐标数据的格式,根据其格式来设计具 体的读取和展绘程序。该实例 Excel 中界址点坐标数据 格式如下:第一行为说明 第二行及其之后各行为数据,即:界址点点名J01J02标石类型混凝土 混凝土X(北坐标)455209.350455217.066Y(东坐标)3143179.1513143181.513高程 H332.176323.234图 3 设计程序的简要流程其主要步骤如下:对 Excel 对象的操作。; 加载扩展的 AutoLISP 函数,并设定 Excel 文件界址点展绘。在该实例中,由于所有界址点都为同种类型的控制点,因此,所有界址点点名都如图4 所示进行展点。图 4 中,J01 为界址点点名,0.36(单 位:mm)为标注的文本框注记点位距该界址点坐标点 位的横向距离,1.4 为标注的文本框注记点位距该界址 点坐标点位的纵向距离。路径(vl-load-com)(setq filename (getfiled 坐标数据 xls 0) (setq exlib C: Program FilesMicrosoft OfficeOFFICE11Excel.exe); 汇入 Excel 应用程序资源库并判断 Excel 资源 库是否被加载(if (null MX-acos)vlax-import-type-library ; 从类库中输出信息图 4 界址点展点图最后结合自定义菜单运行该程序的过程及效果如 图 5 所示。2)提取地块面积至 Excel 表格。在对实测农村承 包地进行面积统计工作时,需将各地块面积及其对应 户主提取出来进行归纳统计以向村民公示,但由于地 块繁多,且某些专业成图软件也不能进行批量提取统: tlb-filename: methods-prefixexlib ; 指定类型库和文件路径MX-; 为方法指定前缀MX-: properties-prefixMX-; 为特性指定前缀MX-; 为常量指定前缀: constants-prefixMX-设定 Excel 文件坐标数据格式加载汇入 Excel 应用程序资源库读取 Excel 坐标数据设置 Text 插入点坐标界址点展绘当前图纸比例缩放)该实例运行结果如图 6 所示。图 5 界址点展点计,因而有必要编写批量提取地块面积至 Excel 文件的 程序。在 CAD 与 Excel 交互操作的过程中,除了可以利 用 VisualLISP 控制访问 ActiveX 对象外,还可以直接利 用 LISP 操作. CSV 格式(逗号分隔值)的文件。之前 曾有人讨论过先将 Excel 格式文件另存为 CSV 格式,通 过批量更改分隔符将数据转换至 DAT 或 TEXT 格式文 件中,最后再与 CAD 交互的方法 7,但该方法同样需 要以 DAT 或 TEXT 文件作为过渡,仍显得有些繁琐。 在此,笔者利用 LISP 对 CSV 格式文件与 CAD 直接进 行交互,提取 CAD 图形中各地块面积至 CSV 文件。首先,设定 CSV 格式文件存储路径,并设定数据 格式:图 6 地块面积统计表截图3结语该实例表明,结合 VisualLISP 开发环境,运用VisualLISP 语言对 CAD 进行二次开发,避免了繁琐的 绘图工作及检查流程,其确实能达到减少大量人工干 预,满足工作需求,提高工作效率的目的,具有很好 的应用前景。参考文献(setq pathcsv 5)(write-line(getfiled 户主面积统计存放路径 1王玉琨,任卫红. CAD 二次开发技术及其工程应用M. 北京:清华大学出版社,2008李学志,方戈亮,孙力红. Visual LISP 程序设计(AutoCAD2006)M. 北京:清华大学出版社,2006李志锐. AutoCAD 二次开发在地形图测绘和城镇规划中的 应用J. 内蒙古农业大学学报, 2006(2):89-97杜磊. CAD 二次开发在地形图入库数据整理中的应用J.测绘与空间地理信息,2010(6):98-99徐泮林,周爱华,刘梁. 数字化成图最新 AutoCAD 地形 图测绘高级开发M.北京:地震出版社,2008 吴永进,林美樱. AutoCAD 完全应用指南M. 北京:科学出 版社,2011刘福臻. 基于数字化成图中的数据格式转换 J. 测绘,2007(5):228-2292(strcat (vl-prin1-to-string 序号/户主名), (vl-prin1-to-string 图上面积 (平方米) )prin1-to-string 图上面积 (亩) ) file), (vl-3其次,对地块图形操作,通过对文字的插入点所在的闭合地块构建面域,求得该面域的实际面积,然 后提取至 CSV 文件中。45(command bpoly pt ); 制作面域6(setq en (entlast); 得到面域实体名7(if en ; 面域创建成功(progn(command area o en) (setq aa1 (getvar area); 求面积; 当前面积平方米第一作者简介:林志鹏,硕士,主要研究方向为 GPS 工程应用与数据处理。地理空间信息第 10 卷第 5 期6GEOSPATIALINFORMATIONIndex (Vol. 10, No. 5)again jitter. The dangerous rock which volume is of 7 104 m3 and ishanging danger rock mass on the steep cliff will slide likely. Underneath of rural roads, village, coal terminal and the safety of the Yangtze River shipping will be under threat. Therefore this article unified nearly several times collapses the disaster, the detailed investigation of the new cracks, the deformation history. Based on the monitor data analysis foundation, it comprehensively analyzed danger rock mass forming pro- cess, the deformation mechanism and the features. The results show that: controlled by composition of a typical hard-soft lithologic associ- ation mode and dangerous rock fracture development situation, be- cause of the long-enduring rainfall, gravity unloaded and emptying dis- turbances such as coal mining under the joint action, dangerous rock mass deformation is instable. At present, the overall displacement di- rection of the dangerous rock body is towards to SW with obvious sub- sidence deformation, and shows a uniform deformation, deformation trend of growing, dangerous rock mass instability.Key words Wangxia dangerous rock mass,collapse,deformationveying and Mapping Achievements, GB/T 19996-2005 Standard for Quality Assessment of Published Mapping Products inspect mul- tiple quality elements in map project, and introduced some methods and practice experience.Key words electronic map,inspection,original map,map tiles(Page:167)Design and Implementation of Celebrating the 90th Anniversary of theFounding of the Communist Partyby YU HuijuanAbstract This paper introduced the design characteristics of Atlas from four respects including the thinking, the contents, the compilation and the publishing .It reflected the historical influence of Gansu liberation and 1911 revolution was represented from a map perspective. And maps atlas will be contributed to the celebration for 90th anniversary of Chinese Commuist Party.Key words red revolution in Gansu,thematic atlas,design,compilation(Page:171)monitoring,deformation mechanism,rainfall(Page:149)Research on Experimental Teaching of Digital Image Processing for GISApplication of VisualLISP Secondary Development Based on CAD inSpecialtyby LV Xiuqinthe Survey of Rural Landby LIN ZhipengAbstract In connection with the characteristics of GIS professional and curriculum, the experimental teaching system of Digital Image Pro- cessing was established firstly. Experimental teaching methods com- bined with Matlab programming and ERDAS applying was designed, and experimental evaluation form of goal setting type and special com- prehensive type was adopted. The practice of the experimental curricu- lum played a more significant role for improving the level and effectiven- ess of Digital Image Processing course.Key words digital image processing,experimental teaching system,Abstract VisualLISP language is a computer programming language within AutoCAD,which serviced to accelerate the provision of second-ary development of CAD . Through some specific examples, this paper proved that VisualLISP Programming could improve operational effi- ciency and reduce labor in rural land survey. VisualLISP Programming is flexibility and efficiency.Key words VisualLISP, AutoCAD, programming, land survey(Page:153)Matlab,ERDAS(Page:174)LBS Services Based on Live Mapsby XU JunAbstract This paper analyzed the market demanding of the Live Maps technology, and summarized the new application mode of real map- based LBS services in government, business and public sectors.Key words Live Maps, Mobile Mapping System, Location Based Ser-Application of Suffer Software in Structural Geology Teachingby LI Zubing Abstract In recent years, because of the rapid development of com- puter technology, they are widely used in different fields. Based on theanalysis of Structural Geology this course on the basis of the charac-teristics, introduced Suffer software, and discussed the Suffer software application in the preparation of construction graph. The application of the planar graph drawing and 3D geological model were analyzed.Key words structural geology, contour map, Suffer software, 3D geol-vice(Page:157)Variable-scale Visualization Based on Map Projection Methodby LI LianyingAbstract Variable-scale visualization is a hot topic recently. This paper introduced an improved method to make variable-scale map based on the map projection method, and carried out some variable-scale maps on Matlab (R2008a) through this method, the result of which was rea- sonable.Key words map projection, variable-scale visualization, cartography(Page:161)(Page:177)ogical modelConstruction of New Learning Evaluation System of Surveying Courseby ZENG YunAbstract In view of the existing problems in Surveying course evalua- tion system, this paper brought up the idea of paying attention to teach-ing process and process evaluation indicators,discussed the principleand some problems in constructing new surveying course evaluation system. The new Surveying course evaluation system will play an im- portant role on stimulating students learning enthusiasm and improving teaching quality.Key words Surveying course,course evaluation system,final assess-Design and Implementation of Map Editor Based on Internetby LI QiAbstract With the development of Internet technology, the way of car- rying out GIS data improved continuously. Mass data widely distributed throughout the network. Map editor based on the local showed its limi- tations. This paper put forward the Map editor based on the Internet, and researched the essential technology of the key process.ment,process assessment(Page:179)Key words map editor,map symbol,REST,WMS(Page:164)Exploration and Practice of Undergraduates Scientific Research Activi-ties in Remote Sensing Laboratory Cent
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 衡水市中医院宫腔镜子宫纵隔切开术专项技能考核
- 2025年福建省福州市鳌峰坊特色历史文化街区招聘1人考前自测高频考点模拟试题附答案详解
- 2025年潍坊滨海经济技术开发区公开招聘中学教师(12人)模拟试卷完整参考答案详解
- 2025福建莆田市城厢区事业单位定向招考未就业随军家属1人考前自测高频考点模拟试题及参考答案详解一套
- 2025湖南省低空经济发展集团有限公司招聘12人(第二次)模拟试卷及一套答案详解
- 2025年陕西电力科隆发展有限责任公司招聘(1人)考前自测高频考点模拟试题含答案详解
- 张家口市中医院中央空调系统运行调节与故障识别试题
- 上海市中医院糖尿病视网膜病变手术考核
- 2025儿童医院吞咽障碍治疗资格认证
- 张家口市中医院黄疸鉴别诊断流程与决策考核
- 2025中数联物流科技(上海)有限公司招聘考试参考试题及答案解析
- 气管插管脱出应急处理
- 急性胰腺炎护理查房
- 2023年贵州专升本英语真题试卷(完整版)
- JSQ5A夹绳器说明书
- 儿童牙外伤处理方法课件
- 《生态毒理学》课件
- DB14T 2740-2023 春玉米膜侧沟播技术规程
- 福特汽车NVH开发流程
- 中国农业银行笔试题库(含答案)
- 《发现雕塑之美》第2课时《凝神造像-中国传统雕塑》
评论
0/150
提交评论