Have you had a look at how xref blocks appear in the database using the MgdDbg tool. You can get this plugin here: http://adndevblog.typepad.com/autocad/2012/04/dwg-debugger-mgddbg-app-for-autocad-20122013.html
I looked into it and it seems that attribute block definitions come into your main drawing with names in an XrefFileName|BlockDefinitionName format. You will see that it uses a vertical pipe symbol to seperate the xref name from the block name.
So say you have an xref drawing named "XREF01.dwg" which contains a block table record with attributes named "MyAttributeBlock", then when you xref it into your main drawing you will get a block table record named "XREF01|MyAttributeBlock".
So here is my suggestion. How about you only access block table records with names that end with a pipe and your block definition name. You can then easily call GetBlockReferenceIds() to get the block references and their attribute values.
Here's what I mean in code...
[CommandMethod("XrefAttributes")]
public static void XrefAttributes()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
foreach (ObjectId btrId in bt)
{
BlockTableRecord btr =
(BlockTableRecord)tr.GetObject(btrId, OpenMode.ForRead);
if (btr.Name.EndsWith("|MyAttBlock"))
{
ObjectIdCollection ids = btr.GetBlockReferenceIds(true, false);
foreach (ObjectId id in ids)
{
BlockReference br =
(BlockReference)tr.GetObject(id, OpenMode.ForRead);
AttributeCollection attc = br.AttributeCollection;
foreach (ObjectId attId in attc)
{
AttributeReference attr =
(AttributeReference)tr.GetObject(
attId,
OpenMode.ForRead
);
ed.WriteMessage("\n" + attr.TextString);
}
}
}
}
tr.Commit();
}
}
The only other option I can think of is to get the xref file names using the XrefGraph and XrefNode classes, and then load them into side databases for-read to search for your data. Try searching "side database" at the following blog for further details on this other technique: http://through-the-interface.typepad.com/
Art