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最新石材線條、木線條圖塊大集合