乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 49|回复: 4

请问怎么提取CAD图形中所有点的坐标啊

[复制链接]

3

主题

5

帖子

2

银币

初来乍到

Rank: 1

铜币
17
发表于 2007-4-12 13:35:00 | 显示全部楼层 |阅读模式
现在我一个CAD图形中,有好多点,我想提取所有点的坐标,保存到EXCEL文件中,用VBA怎么做呢?或者用别的方法
回复

使用道具 举报

15

主题

127

帖子

6

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
187
发表于 2007-4-13 16:44:00 | 显示全部楼层
点是Point还是Block,可以实现输出的。
回复

使用道具 举报

61

主题

163

帖子

7

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
407
发表于 2007-4-14 20:11:00 | 显示全部楼层
先用getpoint方法获取所需要的点,这样点的坐标就可以赋值输出了!
回复

使用道具 举报

1

主题

10

帖子

3

银币

初来乍到

Rank: 1

铜币
14
发表于 2007-5-8 21:52:00 | 显示全部楼层
Dim cName As String
Dim nHandle As String
Dim nScale As Double
Dim nRotation As Double
Dim sLayer As String
Dim yline As Integer
Dim ent As Object
Dim obname As String
Dim xy As Variant
Dim varattr As Variant
Dim attrtxt As Variant
    On Error Resume Next
Dim Excel As Excel.Application '定义excle应用程序变量
'Dim ExcelSheet As Object
Dim ExcelWorkbook As Object '定义工作簿变量
Dim ExcelSheet As worksheet '定义工作表变量
Set Excel = CreateObject("excel.application")  '激活excel程序
Excel.Workbooks.Open ("属性表.xls") '打开工作薄
Set ExcelSheet = Excel.ActiveWorkbook.Sheets("sheet1") '当前工作表为sheet1
'corow = ExcelSheet.UsedRange.Rows.count '计算工作表的总行数
    '创建Excel应用程序实例
'    Set Excel = GetObject(, "Excel.Application")
    '创建一个新工作簿
'    Set ExcelWorkbook = Excel.Workbooks.Add
    '确保Sheet1工作表为当前工作表
'    Set ExcelSheet = Excel.ActiveSheet
'    Set ExcelSheet = Excel.ActiveWorkbook.Sheets("Sheet1")
    '将新创建的工作簿保存为Excel文件
Excel.Visible = False
yline = 2 '写入行位置
For Each ent In ThisDrawing.ModelSpace '在模型空间里循环
  obname = ent.ObjectName '提取对象类型
  If obname = "AcDbBlockReference" Then '判断对象是否为块
    cName = ent.Name        '获取块名
    xy = ent.InsertionPoint '获取插入点坐标
    nHandle = ent.handle    '获取块句柄
    nScale = ent.XScaleFactor     '获取比例
    nRotation = ent.Rotation '获取角度
    sLayer = ent.Layer
   
    varattr = ent.GetAttributes ' 将块属性标记和值复制到varattr变量
    attrtxt(0) = varattr(0).TextString '属性值 0
    attrtxt(1) = varattr(1).TextString '属性值 1
    attrtxt(2) = varattr(2).TextString '属性值 2
   
    ExcelSheet.Cells(yline, 1).Value = nHandle
    ExcelSheet.Cells(yline, 2).Value = cName
    ExcelSheet.Cells(yline, 3).Value = xy(0)
    ExcelSheet.Cells(yline, 4).Value = xy(1)
    ExcelSheet.Cells(yline, 5).Value = xy(2)
    ExcelSheet.Cells(yline, 6).Value = obname
    ExcelSheet.Cells(yline, 7).Value = nScale
    ExcelSheet.Cells(yline, 8).Value = nRotation
    ExcelSheet.Cells(yline, 9).Value = sLayer
    ExcelSheet.Cells(yline, 10).Value = attrtxt(0)  '属性值 0 写入excle文件
    ExcelSheet.Cells(yline, 11).Value = attrtxt(1)  '属性值 1 写入excle文件
    ExcelSheet.Cells(yline, 12).Value = attrtxt(2)  '属性值 1 写入excle文件
    yline = yline + 1 '位置加一行
    attrtxt(0) = ""
    attrtxt(1) = ""
    attrtxt(2) = ""
   End If
Next
Excel.Visible = True
Set Excel = Nothing '释放变量
Set ExcelSheet = Nothing
回复

使用道具 举报

3

主题

12

帖子

6

银币

初来乍到

Rank: 1

铜币
24
发表于 2007-6-23 11:38:00 | 显示全部楼层
请教wenwengg大侠,您给的程序如何使用啊?
我对编程不懂,但我看您写的这个程序是我非常想用的,还望能多多指教!
谢谢!
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-7-6 18:42 , Processed in 1.674910 second(s), 62 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表