for (int i = 0; i < psr.Value.Count; i++)
{
DBObject obj = psr.Value[i].ObjectId.GetObject(OpenMode.ForWrite);
if (!(obj is BlockReference)) continue;
BlockReference blkRef = obj as BlockReference;
BlockTableRecord blkTabRec = blkRef.BlockTableRecord.GetObject(OpenMode.ForWrite) as BlockTableRecord;
if (!blkTabRec.HasAttributeDefinitions) continue;
zb.AttributesUpdate(blkRef);
foreach (ObjectId InnerObject in blkTabRec)
{
Entity TempObject = (Entity)InnerObject.GetObject(OpenMode.ForWrite);
if (!(TempObject is Polyline)) continue;
Polyline poly = TempObject as Polyline;
Point3d ptC = Utilities.Geometry.GetCenterPoint(poly);
ptC = Utilities.Geometry.IsPointInsidePolyline(poly, ptC) ? ptC : poly.GetClosestPointTo(ptC, false);
Point3d ptP = new Point3d(ptC.X + 10f, ptC.Y + 10f, 0);
MLeader lead = Utilities.STD.CreateMLeader(true, zb["zu"].Value);
int idx = lead.AddLeaderLine(ptC);
lead.SetFirstVertex(idx, ptC);
lead.SetLastVertex(idx, ptP);
lead.DoglegLength = 0d;
lead.ArrowSize = 0d;
lead.TextAttachmentDirection = TextAttachmentDirection.AttachmentHorizontal;
lead.TextAlignmentType = TextAlignmentType.CenterAlignment;
lead.TextAttachmentType = TextAttachmentType.AttachmentBottomOfTopLine;
lead.TextHeight = 2.5d;
lead.Layer = LayName;
poly.Color = ColorByBlock;
AdditionalObjects.Add(lead);
}