The code in your post was reformatted by the forum software.
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010
http://www.acadxtabs.com
Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");
wrote in message news:6340892@discussion.autodesk.com...
Here's the way I would do it, but I'm sure there must be a better way -
particularly when it comes to finding an attref's corresponding attdef. If
anyone knows a better solution please post a reply! (Calling TT on the
batphone...) BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId,
OpenMode.ForRead, false); BlockTableRecord blkRecord =
(BlockTableRecord)trans.GetObject(bt[blockName], OpenMode.ForRead, false); //
get all the attribute definitions List attDefs = new List(); // iterate through
& index (by tag) all the block attribute definitions foreach (ObjectId adId in
blkRecord) { DBObject adObj = trans.GetObject(adId, OpenMode.ForRead); // For
each attribute definition we find... AttributeDefinition ad = adObj as
AttributeDefinition; if (ad != null) { attDefs.Add(ad); } } // get all the
attribute references for this block List attRefs = new List(); // iterate
through the references to this block foreach (ObjectId objId in
blkRecord.GetBlockReferenceIds(true, true)) { DBObject obj =
(DBObject)trans.GetObject(objId, OpenMode.ForWrite, false); BlockReference
blockRef = obj as BlockReference; if (blockRef == null) continue; foreach
(ObjectId attrId in blockRef.AttributeCollection) { AttributeReference attRef =
(AttributeReference)trans.GetObject(attrId, OpenMode.ForRead, false);
attRefs.Add(attRef); // To find the corresponding attDef, search through attDefs
to find one with a Tag matching this attRef. // I'd love to know if there's a
better way. // Can TT help? } } // do some nifty stuff with the attributes //...