明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2795|回复: 5

(求助)块属性提取

[复制链接]
发表于 2003-12-18 12:07 | 显示全部楼层 |阅读模式
怎样提取块的插入点坐标??
下面的程序可以提取快标记和属性值
望大侠帮忙修改一下,可以提取插入点坐标
谢谢!!
Sub Ch12_Extract()
    Dim Excel As Excel.Application
    Dim ExcelSheet As Object
    Dim ExcelWorkbook As Object
   
    Dim RowNum As Integer
    Dim Header As Boolean
    Dim elem As AcadEntity
    Dim Array1 As Variant
    Dim Count As Integer

    ' 启动 Excel。
    Set Excel = New Excel.Application
   
    ' 创建新的工作簿并查找活动电子表格。
    Set ExcelWorkbook = Excel.Workbooks.Add
    Set ExcelSheet = Excel.ActiveSheet
    ExcelWorkbook.SaveAs "Attribute.xls"
   
    RowNum = 1
    Header = False
    ' 遍历模型空间,查找
    ' 所有的块引用。
    For Each elem In ThisDrawing.ModelSpace
        With elem
            ' 找到块引用时,
            ' 检查其属性
            If StrComp(.EntityName, "AcDbBlockReference", 1) _
                = 0 Then
                If .HasAttributes Then
                    ' 获取属性
                    Array1 = .GetAttributes
                    ' 将属性的标记字符串
                    ' 复制到 Excel
                    For Count = LBound(Array1) To UBound(Array1)
                        If Header = False Then
                            If StrComp(Array1(Count).EntityName, _
                                  "AcDbAttribute", 1) = 0 Then
                                ExcelSheet.Cells(RowNum, _
                                    Count + 1).value = _
                                    Array1(Count).TagString
                            End If
                        End If
                    Next Count
                    RowNum = RowNum + 1
                    For Count = LBound(Array1) To UBound(Array1)

                        ExcelSheet.Cells(RowNum, Count + 1).value = Array1(Count).TextString
                    Next Count
                    Header = True
                End If
            End If
        End With
    Next elem
    Excel.Application.Quit
End Sub
发表于 2003-12-18 13:48 | 显示全部楼层

  1. dim v as variant
  2. For Each elem In ThisDrawing.ModelSpace
  3.         With elem
  4.            If StrComp(.EntityName, "AcDbBlockReference", 1)  = 0 Then
  5.                v=.InsertionPoint
  6.                 ExcelSheet.Cells(RowNum,  1).value = v(0)
  7.                 ExcelSheet.Cells(RowNum,  2).value = v(1)     
  8.                 ExcelSheet.Cells(RowNum,  3).value = v(2)
  9.                 RowNum = RowNum + 1
  10.             End If
  11.          End With
  12.     Next elem
复制代码
 楼主| 发表于 2003-12-18 13:41 | 显示全部楼层
自己顶
 楼主| 发表于 2003-12-19 16:08 | 显示全部楼层
thanks
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-4-25 13:47 , Processed in 0.282925 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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