MLeaderStyle CenterCenter

#1
Hello, I have the problem to generate a MLLeader Style "Center-Center"

//---------------------------------------------------------------------------------
internal static bool CrtMlStyleCenterCenter(out ObjectId MlStylID)
{
Document acDoc = Application.DocumentManager.MdiActiveDocument;
Editor DocEd = acDoc.Editor;
Database acCurDb = acDoc.Database;
DBDictionary MlStylTabDic;
MLeaderStyle CenterCenter, Std = new MLeaderStyle();
ObjectId StdStyl = ObjectId.Null;
string MlStylNam = "CENTER-CENTER";
MlStylID = ObjectId.Null;
//--------------------------------------------------------------------------
using (DocumentLock acLckDoc = acDoc.LockDocument())
{
using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
{
MlStylTabDic = acTrans.GetObject(acCurDb.MLeaderStyleDictionaryId, OpenMode.ForRead) as DBDictionary;
if (MlStylTabDic.Contains(MlStylNam))
{
MlStylID = MlStylTabDic.GetAt(MlStylNam);
return true;
}
//---------------------------------------------------
foreach (DBDictionaryEntry DbEntry in MlStylTabDic)
{
MLeaderStyle StylTmp = acTrans.GetObject(DbEntry.Value, OpenMode.ForRead) as MLeaderStyle;
if (StylTmp.Name.Equals("STANDARD", StringComparison.OrdinalIgnoreCase))
{
Std = StylTmp;
}
}
//---------------------------------------------------
CenterCenter = new MLeaderStyle(Std);
CenterCenter.Name = MlStylNam;
//CenterCenter.SetTextAttachmentType(TextAttachmentType.AttachmentMiddle, LeaderDirectionType.LeftLeader); // AutoCad
//CenterCenter.SetTextAttachmentType(TextAttachmentType.AttachmentMiddle, LeaderDirectionType.RightLeader); // AutoCad
CenterCenter.TextAttachmentType = TextAttachmentType.AttachmentMiddle; // I-CAD hang
CenterCenter.TextAlignmentType = TextAlignmentType.CenterAlignment; // I-CAD hang
MlStylID = CenterCenter.PostMLeaderStyleToDb(acCurDb, MlStylNam);
acTrans.AddNewlyCreatedDBObject(CenterCenter, true);
//---------------------------------------------------
acTrans.Commit();
}
}
return MlStylID != ObjectId.Null;
}
//---------------------------------------------------------------------------------