theone Posted November 28, 2008 Posted November 28, 2008 Hi frnds, I have a dwg file which contains thousands of blockrefrence type objects What i want is..... for each block(block refrence type) in thedrawing get its layer name get is block name nd get its block attributes next all this should be exported in the excel file I have coded but it seems i m not getting the thing i want Public Sub ChTitle_click() Dim acadOBJ As AcadObject Dim oEnt As AcadEntity Dim oAtt As AcadAttributeReference Dim varAtts As Variant Dim varName As Variant Dim varLayer As Variant Dim varSwitchGearNo As Variant Dim i, j, z As Integer i = j = 0 'connect to excel Dim oExcel As Excel.Application Dim oBook As Excel.Workbook Dim oSheet As Excel.Worksheet Dim nRow As Integer 'Open Excel Set oExcel = New Excel.Application oExcel.Visible = True 'Set oBook = oExcel.Workbooks.Add("C:\trial.xls") ' Optional Set oBook = oExcel.Workbooks.Add() Set oSheet = oBook.Sheets("Sheet1") ' With oSheet oSheet.Cells(1, 1).Borders.LineStyle = xlContinuous oSheet.Cells(1, 1).Font.Bold = True oSheet.Cells(1, 1) = "FEEDER ID" oSheet.Cells(1, 2).Borders.LineStyle = xlContinuous oSheet.Cells(1, 2).Font.Bold = True oSheet.Cells(1, 2) = "SwitchGear Type" oSheet.Cells(1, 3).Borders.LineStyle = xlContinuous oSheet.Cells(1, 3).Font.Bold = True oSheet.Cells(1, 3) = "SwitchGear No" 'Variable declaration Dim nStartwriting As Integer nStartwriting = 2 'For Each oEnt In ThisDrawing.ModelSpace For Each oEnt In ThisDrawing.ModelSpace If TypeName(oEnt) = "IAcadBlockReference" Then oSheet.Cells(nStartwriting, 1) = oEnt.Layer oSheet.Cells(nStartwriting, 2) = oEnt.Name If oEnt.HasAttributes Then varAtts = oEnt.GetAttributes For i = 0 To UBound(varAtts) ReDim varSwitchGearNo(j) As Variant oSheet.Cells(nStartwriting, 3) = varAtts(i).TextString ' varSwitchGearNo(j) = varAtts(i).TextString j = j + 1 Next i End If nStartwriting = nStartwriting + 1 End If Next Call oBook.Close(True, "C:\" & "SLD" & ".xls") oExcel.DisplayAlerts = False oExcel.Quit End Sub Anyone, what i m doing wrong Quote
borgunit Posted December 1, 2008 Posted December 1, 2008 Rather than trying to figure it out, what exactly does it do? Does it fail? Does it put in wrong info? A little more specific please. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.