明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1514|回复: 3

[求助]怎么调出CAD中直线的坐标值

[复制链接]
发表于 2007-6-2 11:39:00 | 显示全部楼层 |阅读模式
在CAD模型空间里随便画一条直线
然后用VBA编程输出该直线的起始点和结束点坐标值
Sub OpenDrawing()

Dim LineObj As AcadLine
Dim a As Variant
Dim b As Variant
Set LineObj = ThisDrawing.ModelSpace.Item(0)
a = LineObj.StartPoint
b = LineObj.EndPoint
MsgBox "a=" & a & "    b=" b

End Sub

我做出以上程序,但是运行不出来,望高手指教,谢谢!
 楼主| 发表于 2007-6-2 11:41:00 | 显示全部楼层
本人急用此程序,全天候在线等回答,请高手帮忙,感激不尽!
发表于 2007-6-2 11:59:00 | 显示全部楼层
Sub OpenDrawing()
Dim LineObj As AcadLine
Dim a As Variant
Dim b As Variant
Dim x(2) As Double, Y(2) As Double
Dim xx(2) As Double, yy(2) As Double
x(0) = 10: x(1) = 10: x(2) = 0
Y(0) = 50: Y(1) = 50: Y(2) = 0
Set LineObj = ThisDrawing.ModelSpace.AddLine(x, Y)
a = LineObj.StartPoint
b = LineObj.EndPoint
xx(0) = a(0): xx(1) = a(1)
yy(0) = b(0): yy(1) = b(1)
  MsgBox "xx=" & xx(0) & "    xx=" & xx(1)
  MsgBox "yy=" & yy(0) & "    yy=" & yy(1)
End Sub
发表于 2007-6-2 12:07:00 | 显示全部楼层
Sub OpenDrawing()
Dim LineObj As AcadLine
Dim a As Variant
Dim b As Variant
Dim x(2) As Double, Y(2) As Double
Set LineObj = ThisDrawing.ModelSpace.Item(0)
a = LineObj.StartPoint
b = LineObj.EndPoint
x(0) = a(0): x(1) = a(1)
Y(0) = b(0): Y(1) = b(1)
  MsgBox "x=" & x(0) & "    x=" & x(1)
  MsgBox "y=" & Y(0) & "    y=" & Y(1)
End Sub
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-2-22 18:29 , Processed in 0.172932 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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