Sub dd()
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 Object
Dim ExcelSheet As Object
Dim ExcelWorkbook As Object
'创建Excel应用程序实例
On Error Resume Next
Set Excel = GetObject(, "Excel.Application")
Set ExcelSheet = Excel.ActiveSheet
Excel.Visible = True
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
End Sub
相关文章
- 2018-04-20CCD设计CAD图层标准平立面模块图库及节点图
- 2018-04-09未来城B1区块某培训中心CAD施工图+高清效果图
- 2016-05-01上海徐泾三号地块项目E2户型精装修竣工图
- 2016-02-16电器洁具灯具常用CAD平面立面图块下载
- 2016-01-30CCD设计专业CAD图库图块大全免费下载
- 2016-01-14高文安启东中邦城中城A1地块联排别墅现代古典施工图
- 2015-08-25vliman欧式超复杂柜体大全CAD图块下载
- 2015-08-23中式古典花格元素CAD图块大全下载
- 2015-04-09HBA图块和ONLEAD办公家具平面图总汇
- 2015-03-24CAD最新石材线条、木线条图块大集合