明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 4427|回复: 5

[求助]CAD中坐标值批量转移到EXCEL中

[复制链接]
发表于 2008-7-1 10:37:00 | 显示全部楼层 |阅读模式

我想把CAD中光标所点的坐标值批量转移到EXCEL表格中。

例如:我打开一张CAD图形,上面有好多圆,我每点击一下(仅扑捉点击圆心),就会在EXCEL表格中按顺序把我点击的坐标数值显示出来

点号         X            Y

1           3000       2000

2           1000       2000

3           4000       3000

……

请高手帮我解决这个问题,谢谢!(能不能用一个lisp程序,把cad指定点坐标导出到EXCEL)?

发表于 2008-7-1 11:14:00 | 显示全部楼层

可以

可以帮到你的忙的,我的联系方式是QQ375564896
发表于 2008-7-8 08:08:00 | 显示全部楼层

你可以先创建一个记事本。先把坐标导入记事本在导入excel

Dim us3 As Integer '左下角Y坐标
us1 = ThisDrawing.GetVariable("userr1")
us2 = ThisDrawing.GetVariable("userr2")
us3 = ThisDrawing.GetVariable("userr3")
'Dim pnt_cord(0 To 1) As Double
Dim sset As AcadSelectionSet
Dim i As Integer

For i = 0 To ThisDrawing.SelectionSets.Count - 1
ThisDrawing.SelectionSets.Item(i).Clear
ThisDrawing.SelectionSets.Item(i).Delete
Next
ft(0) = 0
fd(0) = "Point"
Set sset = ThisDrawing.SelectionSets.Add("Sset_P")
sset.Select acSelectionSetAll, , , ft, fd
ReDim pnt_cord(sset.Count - 1) As Variant
ReDim x(sset.Count - 1)
ReDim y(sset.Count - 1)
dnr = ""

For i = 0 To sset.Count - 1
pnt_cord(i) = sset.Item(i).Coordinates

Select Case us1
Case 500
If us2 = 0 And us3 = 0 Then
x(i) = (pnt_cord(i)(1) - 100) / 2
y(i) = (pnt_cord(i)(0) - 100) / 2
ElseIf us2 = 100 And us3 = 100 Then
x(i) = (pnt_cord(i)(1) + 100) / 2
y(i) = (pnt_cord(i)(0) + 100) / 2
End If
Case 1000
If us2 = 0 And us3 = 0 Then
x(i) = pnt_cord(i)(1) - 100
y(i) = pnt_cord(i)(0) - 100
ElseIf us2 = 100 And us3 = 100 Then
x(i) = pnt_cord(i)(1)
y(i) = pnt_cord(i)(0)
End If

End Select


'*******按scs2000展点文件格式排列点
dnr = dnr & vbCrLf & (i + 1) & vbCrLf & "" & vbCrLf & y(i) & vbCrLf & x(i) & vbCrLf & pnt_cord(i)(2)

Next
outtxt = sset.Count & dnr
MsgBox "点导出成功,请保存文件!"
End Sub

发表于 2009-4-16 23:49:00 | 显示全部楼层

谢谢共享!

发表于 2010-2-22 17:48:00 | 显示全部楼层
是个好东西,不知是否可行啊。
发表于 2010-2-24 19:31:00 | 显示全部楼层
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-2-27 19:50 , Processed in 0.175871 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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