AttributeReference ar = someAttRef;
Point3d attPos = someAttRef.Position;
I have not had a chance to work with dynamic blocks programmatically yet so I am not sure about what is involved with them along those lines.
The attribute ref position is relative to the position of the block that contains it. When you place a block reference that has an attribute definition programmatically, in order for the attribute def to be placed correctly you have to figure for the block's position (transformation matrix). The attribute would be transformed using the block ref 'BlockTransform' property. This is a sample of what I have used before:
using (Transaction trans = transMgr.StartTransaction())
{
BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead);
BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
string blockName = "SOME BLOCK NAME";
if (!bt.Has(blockName))
{
editor.WriteMessage("\nFunction Cancelled! --> Block '" + blockName + "' not found.");
trans.Dispose();
return;
}
DatabaseServ.ObjectId bdId = bt[blockName];
DatabaseServ.BlockReference blockRef = new DatabaseServ.BlockReference(new Point3d(5, 5, 0), bdId);
BlockTableRecord bdr = (BlockTableRecord)trans.GetObject(bdId, OpenMode.ForRead);
foreach (DatabaseServ.ObjectId id in bdr)
{
DatabaseServ.Entity ent = (DatabaseServ.Entity)trans.GetObject(id, OpenMode.ForRead);
if (ent is AttributeDefinition)
{
AttributeDefinition ad = (AttributeDefinition)ent;
AttributeReference ar = new AttributeReference();
// This is the key here:
ar.SetAttributeFromBlock(ad, blockRef.BlockTransform);
blockRef.AttributeCollection.AppendAttribute(ar);
trans.AddNewlyCreatedDBObject(ar, true);
}
}
trans.commit();
}