明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1662|回复: 4

当平移直线后,怎样通过VBA得到平移的距离?

[复制链接]
发表于 2005-4-16 11:19:00 | 显示全部楼层 |阅读模式
求救:当在AutoCAD中选择一条直线后,运行move命令后,怎样通过VBA立即获取它移动的距离,移动后起点,端点坐标?
发表于 2005-4-16 15:44:00 | 显示全部楼层
本帖最后由 作者 于 2005-4-17 6:11:26 编辑

我对VBA不太熟悉,所以试着写了一个,请大家指正 Sub move_line()
Dim lineobj As AcadLine
Dim lineobj1 As AcadLine
Dim point_1 As Variant
Dim point_2 As Variant
Dim length As Double
Dim aa As String, bb As String ThisDrawing.Utility.GetEntity lineobj, pt, "选择要移动的直线:"
point_1 = ThisDrawing.Utility.GetPoint(, "输入基准点:")
point_2 = ThisDrawing.Utility.GetPoint(, "输入第二点:")
lineobj.Move point_1, point_2
aa = Str(lineobj.StartPoint(0)) + "," + Str(lineobj.StartPoint(1)) + "," + Str(lineobj.StartPoint(2))
bb = Str(lineobj.EndPoint(0)) + "," + Str(lineobj.EndPoint(1)) + "," + Str(lineobj.EndPoint(2))
ThisDrawing.Regen acAllViewports
Set lineobj1 = ThisDrawing.ModelSpace.AddLine(point_1, point_2)
length = lineobj.length
lineobj1.Delete
MsgBox "移动长度为: " & length & vbCrLf & "起点坐标为:" & aa & vbCrLf & "终点坐标为:" & bb End Sub
 楼主| 发表于 2005-4-17 09:43:00 | 显示全部楼层
谢谢~~
发表于 2005-4-21 15:37:00 | 显示全部楼层
请教版主:


怎样用VBA选择多线段,并显示多线段的面积?


谢谢!!
发表于 2005-4-21 15:43:00 | 显示全部楼层
怎样用VBA选择多线段,并显示多线段的面积?


选择就是选择一个entity         然后重新赋值给polyline


面积就是area属性
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-27 16:32 , Processed in 0.183839 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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