public static string GetBlockConstantAttributes(ObjectId bRefId)
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = doc.Database;
Dictionary<string, int> atts = new Dictionary<string, int>
{
{"LENGTH", 0},
{"WIDTH", 1},
{"FILLET", 2},
{"ASSEMBLY", 3}
};
string[] content = new string[atts.Count];
using (Transaction tr = doc.TransactionManager.StartTransaction())
{
// получить BlockReference
BlockReference br =
tr.GetObject(bRefId, OpenMode.ForRead) as BlockReference;
// получить его BlockTableRecord
BlockTableRecord btr =
tr.GetObject(br.BlockTableRecord, OpenMode.ForRead) as BlockTableRecord;
foreach (ObjectId id in btr)
{
if (id.ObjectClass == RXObject.GetClass(typeof(AttributeDefinition)))
{
AttributeDefinition att =
tr.GetObject(id, OpenMode.ForRead) as AttributeDefinition;
if (att.Constant && atts.TryGetValue(att.Tag.ToUpper(), out int i))
{
content[i] = att.TextString;
}
}
}
tr.Commit();
}
return string.Join(" ", content);
}