using (Transaction rbTrans = db.TransactionManager.StartTransaction())
{
BlockReference bref = (BlockReference)rbTrans.GetObject(bed, OpenMode.ForRead);
BlockTableRecord bdef = (BlockTableRecord)rbTrans.GetObject(bref.BlockTableRecord, OpenMode.ForRead);
if (bdef.HasAttributeDefinitions != true) return null;
foreach (ObjectId id in bdef)
{
DBObject obj = (DBObject)rbTrans.GetObject(id, OpenMode.ForRead, true);
AttributeDefinition attdef = obj as AttributeDefinition;
if ((attdef != null) && (!attdef.Constant))
{
if (attdef.Tag == "pos_Origin_Z")
{
structure.insPtZ = attdef.TextString;
}
else if ((attdef.Tag == "pos_Endpoint_Z"))
{
structure.endPtZ = attdef.TextString;
}
else if ((attdef.Tag == "prd_UL"))
{
structure.uLabel = attdef.TextString;
}
else if ((attdef.Tag == "prd_LP"))
{
structure.layPos = attdef.TextString;
}
}
}
structure.insPt = bref.Position;
structure.blkName = ((BlockTableRecord)bref.DynamicBlockTableRecord.GetObject(OpenMode.ForRead)).Name;
structure.lyrName = bref.Layer;
structure.rotAngle = bref.Rotation;
rbTrans.Dispose();
return structure;
}