CADdancer
2007-10-10, 04:24 PM
Hello AUGI Members,
I am trying to extract information from AutoCAD "Dynamic Blocks" into an Excel spread sheet. I have developed the segment of code below that worked fine when I was using normal blocks with attributes however, it does not work properly with Dynamic Blocks. I have tried to use the "Effective Name" property but I still get incorrect results.
If StrComp(.EntityName, "AcDbBlockReference", 1) = 0 Then
If StrComp(Left(.Name, 3), UCase(PartEnt.EffectiveName) = UCase("SB1"), vbTextCompare) = 0 Then '
If .HasAttributes Then
Array1 = .GetAttributes
For count = LBound(Array1) To UBound(Array1)
If Header = False Then
If RowNum = 1 Then
iFoo = 1
excelSheet.Cells(RowNum, iFoo).Font.Bold = True
excelSheet.Cells(RowNum, iFoo).Value = "STEEL REPORT"
RowNum = RowNum + 1
iFoo = 0
End If
If StrComp(Array1(count).EntityName, "AcDbAttribute", 1) = 0 Then
'do not print the first element btag because it is a duplicate
If Array1(count).TagString <> "BTAG" Then
iFoo = iFoo + 1
excelSheet.Cells(RowNum, iFoo).HorizontalAlignment = xlCenter
excelSheet.Cells(RowNum, iFoo).Font.Bold = True
excelSheet.Cells(RowNum, iFoo).Value = Array1(count).TagString
End If
End If
End If
Next count
RowNum = RowNum + 1 'New row
iSkip = 0 'Do not print the first element in the collection
iFoo = 0 'Reset the column counter
For count = LBound(Array1) To UBound(Array1)
'If break of member then print summary record
If count <> iSkip Then
iFoo = iFoo + 1
If count <> 2 Then
excelSheet.Cells(RowNum, iFoo).Value = Array1(count).TextString
Else
excelSheet.Cells(RowNum, iFoo).Style.Name = "Number"
excelSheet.Cells(RowNum, iFoo).Value = CDbl(Array1(count).TextString)
End If
End If
Next count
Header = True
End If
End If
End If
End With
Next elem
Can someone with more VBA experience help me with the correct use of the "EffectiveName" property to filter for the dynamic blocks named "SB1".
Any assistance would be appreciated...!
Regards,
Vince
I am trying to extract information from AutoCAD "Dynamic Blocks" into an Excel spread sheet. I have developed the segment of code below that worked fine when I was using normal blocks with attributes however, it does not work properly with Dynamic Blocks. I have tried to use the "Effective Name" property but I still get incorrect results.
If StrComp(.EntityName, "AcDbBlockReference", 1) = 0 Then
If StrComp(Left(.Name, 3), UCase(PartEnt.EffectiveName) = UCase("SB1"), vbTextCompare) = 0 Then '
If .HasAttributes Then
Array1 = .GetAttributes
For count = LBound(Array1) To UBound(Array1)
If Header = False Then
If RowNum = 1 Then
iFoo = 1
excelSheet.Cells(RowNum, iFoo).Font.Bold = True
excelSheet.Cells(RowNum, iFoo).Value = "STEEL REPORT"
RowNum = RowNum + 1
iFoo = 0
End If
If StrComp(Array1(count).EntityName, "AcDbAttribute", 1) = 0 Then
'do not print the first element btag because it is a duplicate
If Array1(count).TagString <> "BTAG" Then
iFoo = iFoo + 1
excelSheet.Cells(RowNum, iFoo).HorizontalAlignment = xlCenter
excelSheet.Cells(RowNum, iFoo).Font.Bold = True
excelSheet.Cells(RowNum, iFoo).Value = Array1(count).TagString
End If
End If
End If
Next count
RowNum = RowNum + 1 'New row
iSkip = 0 'Do not print the first element in the collection
iFoo = 0 'Reset the column counter
For count = LBound(Array1) To UBound(Array1)
'If break of member then print summary record
If count <> iSkip Then
iFoo = iFoo + 1
If count <> 2 Then
excelSheet.Cells(RowNum, iFoo).Value = Array1(count).TextString
Else
excelSheet.Cells(RowNum, iFoo).Style.Name = "Number"
excelSheet.Cells(RowNum, iFoo).Value = CDbl(Array1(count).TextString)
End If
End If
Next count
Header = True
End If
End If
End If
End With
Next elem
Can someone with more VBA experience help me with the correct use of the "EffectiveName" property to filter for the dynamic blocks named "SB1".
Any assistance would be appreciated...!
Regards,
Vince