Hello Ed,
Well im inserting blocks from a self made tool pallete in Plant P&ID. Then I try to access them with the following code and retrieve the insertion point: ( I found the code on the Internet and modified it slightly)
.........................................................................................................................................................
Public Sub test()
Dim sset As AcadSelectionSet
Dim ent As AcadEntity
Dim Book1 As Object
Dim Sheet1 As Object
Dim xlApp As Object
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
Set Book1 = xlApp.Workbooks.Add()
Set Sheet1 = Book1.worksheets(1)
Dim i As Integer
'Select all that are on the dup layer
On Error Resume Next
ThisDrawing.SelectionSets.Item("layer").Delete
On Error GoTo 0
Set sset = ThisDrawing.SelectionSets.Add("layer")
sset.Select acSelectionSetAll
Dim inPt As Variant
i = 1
For Each ent In sset
'Debug.Print ent.IsXRef
' inPt = ent.InsertionPoint
' End If
If TypeOf ent Is AcadBlockReference Then
Dim varAttributes As Variant
varAttributes = ent.GetAttributes
'Debug.Print "hello"
' Debug.Print ent.Name
If InStr(ent.EffectiveName, "$") = 0 Then
inPt = ent.InsertionPoint
Sheet1.Cells(i, 1) = inPt(0)
Sheet1.Cells(i, 2) = inPt(1)
Sheet1.Cells(i, 3) = ent.EffectiveName
Sheet1.Cells(i, 4) = ent.ObjectName
For t = 0 To UBound(varAttributes)
Debug.Print varAttributes(t).TagString
Next
i = i + 1
End If
End If
Next
End Sub
.........................................................................................................................................................
If I add a Block directly from my tool pallete I will not get it in the excel list. If however I add the Block as a Blockreference from the Insert tab then It will show up and I can get the Insertion Point.
HB.