public void CreatingMleaderStyle()
{
using (Transaction tr = db.TransactionManager.StartTransaction())
{
DBDictionary mleaderStylesDict = tr.GetObject(db.MLeaderStyleDictionaryId, OpenMode.ForRead) as DBDictionary;
const String mleaderStyleName = "Мультивыноски";
MLeaderStyle mleaderStyle;
if (mleaderStylesDict.Contains(mleaderStyleName))
{
mleaderStyle = (MLeaderStyle)tr.GetObject((ObjectId)mleaderStylesDict[mleaderStyleName], OpenMode.ForWrite);
mleaderStyleId = mleaderStylesDict.GetAt(mleaderStyleName);
}
else
{
mleaderStyle = new MLeaderStyle();
mleaderStyle.ContentType = ContentType.MTextContent;
mleaderStyle.TextAlignmentType = TextAlignmentType.LeftAlignment;
mleaderStyle.TextAttachmentType = TextAttachmentType.AttachmentMiddleOfTop;
mleaderStyle.TextAngleType = TextAngleType.HorizontalAngle;
mleaderStyle.TextAttachmentDirection = TextAttachmentDirection.AttachmentHorizontal;
mleaderStyle.EnableFrameText = false;
mleaderStyle.ArrowSize = 2;
mleaderStyle.Annotative = AnnotativeStates.True;
mleaderStyle.LeaderLineTypeId = db.ByBlockLinetype;
mleaderStyle.LeaderLineType = LeaderType.StraightLeader;
mleaderStyle.LandingGap = 0.1;
mleaderStyle.DoglegLength = 0.1;
mleaderStyle.MaxLeaderSegmentsPoints = 2;
mleaderStyle.BreakSize = 2;
ObjectId textStyleId = ObjectId.Null;
TextStyleTable tst = (TextStyleTable)tr.GetObject(db.TextStyleTableId, OpenMode.ForWrite);
TextStyleTableRecord textStyle = new TextStyleTableRecord();
textStyle.Name = "ISOCPEUR";
textStyle.FileName = "isocpeur.ttf";
textStyle.XScale = 1;
if (!tst.Has(textStyle.Name))
{
tst.Add(textStyle);
tr.AddNewlyCreatedDBObject(textStyle, true);
}
textStyleId = tst[textStyle.Name];
mleaderStyle.TextStyleId = textStyleId;
mleaderStyle.TextAlignAlwaysLeft = false;
mleaderStyle.TextHeight = 1.5;
mleaderStyleId = mleaderStyle.PostMLeaderStyleToDb(db, mleaderStyleName);
tr.AddNewlyCreatedDBObject(mleaderStyle, true);
mleaderStyleId = mleaderStylesDict.GetAt(mleaderStyleName);
db.MLeaderstyle = mleaderStyleId;
}
tr.Commit();
}
}