明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
楼主: surveynet

AutoCAD二次开发(VBA)测绘篇

    [复制链接]
发表于 2009-10-15 18:48 | 显示全部楼层
先谢谢好心的你了!希望以后多发一些有用的资料,非常感激
发表于 2009-10-15 20:02 | 显示全部楼层

一般用法是ThisDrawing.ModelSpace

ThisDrawing.Application.ActiveDocument.ModelSpace的用法虽然正确,但不常用。

见下载程序的两个示例。

Sub EditLwPolyline()
   Dim objLwPl As AcadLWPolyline
   Dim xy(5) As Double
   xy(0) = 100: xy(1) = 200
   xy(2) = 300: xy(3) = 300
   xy(4) = 500: xy(5) = 600
   Set objLwPl = ThisDrawing.Application.ActiveDocument.ModelSpace.AddLightWeightPolyline(xy)
   objLwPl.Closed = True '闭合
   objLwPl.ConstantWidth = 0 '全局宽度
   objLwPl.Linetype = "10421" '线型(加载了才可用)
   objLwPl.Highlight True '高亮显示
   MsgBox "ID=" & objLwPl.ObjectID
   MsgBox "类型=" & objLwPl.ObjectName
   MsgBox "句柄=" & objLwPl.Handle
   MsgBox "多段线坐标为:(" & objLwPl.Coordinates(0) & "," & objLwPl.Coordinates(1) & "),(" & objLwPl.Coordinates(2) & "," & objLwPl.Coordinates(3) & "),(" & objLwPl.Coordinates(4) & "," & objLwPl.Coordinates(5) & ")"
End Sub
Sub EditText()
   Dim objText As AcadText
   Dim xy(2) As Double
   xy(0) = 100: xy(1) = 200: xy(2) = 300
   Set objText = ThisDrawing.Application.ActiveDocument.ModelSpace.AddText("Hello World!", xy, 30)
   MsgBox "插入点位置" & objText.insertionPoint(0) & "," & objText.insertionPoint(1) & "," & objText.insertionPoint(2) & ")"
   objText.Alignment = acAlignmentBottomRight '对齐方式
   objText.height = 20 '高度
   objText.StyleName = "STANDARD" '样式
   objText.TextString = "AutoCAD VBA 测绘" '文字内容
End Sub

发表于 2009-10-17 20:55 | 显示全部楼层
晕,又不说清楚,白花了我1元大洋
发表于 2009-10-21 16:02 | 显示全部楼层

下载了看看,谢谢哈

发表于 2009-10-31 16:31 | 显示全部楼层

学习一下 下载看啊看你

发表于 2009-10-31 22:44 | 显示全部楼层
还要钱 干什么?
发表于 2009-11-13 15:30 | 显示全部楼层
不错,适合初学的!
发表于 2009-11-14 15:46 | 显示全部楼层

看着像是好东西,因为我也是干测绘的,可是怎么下不下来呢?

发表于 2009-11-15 15:21 | 显示全部楼层
下载学习,学习
发表于 2009-11-16 11:42 | 显示全部楼层

非常好.谢谢楼主的大公无私

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-4-23 15:08 , Processed in 0.470521 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表