Thanks for the help. But it works only to count block references in each layout. What I need is to be able to edit attributes in block references in different layers. Since I cannot change the active layout via ODBX, the paperspace collection only contains objects in the active layout when the drawing was saved. I can access any block reference using the block property of the layout, but I cannot read its attributes with GetAttributes method. Every time I try to use GetAttributes on a block reference, it returns the attributes of the block reference instance located in the active layout. I'm doing this (ommiting the variable declarations):
Set objDbx = GetInterfaceObject("ObjectDBX.AxDbDocument.20")
objDbx.Open "C:\Temp\Test.dwg"
For Each lay In objDbx.Layouts
If lay.Name <> "Model" Then
For Each elem In lay.Block
If elem.ObjectName = "AcDbBlockReference" Then
If elem.HasAttributes Then
a = elem.GetAttributes
'Here I read attributes scanning the a array
End If
End If
Next
End If
Next
Set objDbx = Nothing
In my sample drawing I have 8 layouts, each one with a block with an attribute called "page". In layout 1 it holds "1", in layout 2 it holds "2" and so on. But when I read the "a" array, it always returns "8", the value matching the layout 8 that is the last active layout when the file was saved. Maybe ODBX cannot handle this method; maybe I am doing something wrong. Have you any idea of what could be happening? Can I provide more information?