public static void CreateStyle()
{
using (Db.Transaction tr = db.TransactionManager.StartTransaction())
{
ObjectId txtStyleId;
TextStyleTable sourceTable = (TextStyleTable)tr.GetObject(db.TextStyleTableId, OpenMode.ForRead);
TextStyleTableRecord textStyle = null;
Db.TextStyleTable tst = (Db.TextStyleTable)tr.GetObject(db.TextStyleTableId, Db.OpenMode.ForWrite);
textStyle.Name = "Text";
textStyle.FileName = "GOST type A.TTF";
textStyle.ObliquingAngle = 15 * Math.PI / 180;
textStyle.XScale = 0.75;
tst.Add(textStyle);
tr.AddNewlyCreatedDBObject(textStyle, true);
txtStyleId = textStyle.ObjectId;
Db.DimStyleTable dst = (Db.DimStyleTable)tr.GetObject(db.DimStyleTableId, Db.OpenMode.ForWrite);
Db.DimStyleTableRecord dimStyle = new Db.DimStyleTableRecord();
dimStyle.Name = "Basic";
Db.ObjectId lineTypeId = db.ByLayerLinetype;
Clr.Color colorByLayer = Clr.Color.FromColorIndex(Clr.ColorMethod.ByLayer, 256);
dimStyle.Dimclrd = colorByLayer;
dimStyle.Dimltype = lineTypeId;
dimStyle.Dimlwd = Db.LineWeight.ByLineWeightDefault;
dimStyle.Dimdle = 2;
dimStyle.Dimdli = 7;
dimStyle.Dimsd1 = false;
dimStyle.Dimsd2 = false;
dimStyle.Dimclre = colorByLayer;
dimStyle.Dimltex1 = lineTypeId;
dimStyle.Dimltex2 = lineTypeId;
dimStyle.Dimlwe = Db.LineWeight.ByLineWeightDefault;
dimStyle.Dimse1 = false;
dimStyle.Dimse2 = false;
dimStyle.Dimexe = 1.25;
dimStyle.Dimexo = 0;
dimStyle.DimfxlenOn = false;
dimStyle.Dimfxlen = 1;
Db.BlockTable bt = (Db.BlockTable)tr.GetObject(db.BlockTableId, Db.OpenMode.ForRead);
dimStyle.Dimsah = true;
dimStyle.Dimblk1 = Db.ObjectId.Null;
dimStyle.Dimblk2 = Db.ObjectId.Null;
dimStyle.Dimldrblk = Db.ObjectId.Null;
dimStyle.Dimasz = 3;
Int32 centerMarks = 1;
Double centerMarksSize = 2.5;
dimStyle.Dimcen = centerMarks * centerMarksSize;
Db.RegAppTable regTable = (Db.RegAppTable)tr.GetObject(db.RegAppTableId, Db.OpenMode.ForRead);
String xName = "cad_DSTYLE_DIMBREAK";
if (!regTable.Has(xName))
{
regTable.UpgradeOpen();
Db.RegAppTableRecord app = new Db.RegAppTableRecord();
app.Name = xName;
regTable.Add(app);
tr.AddNewlyCreatedDBObject(app, true);
}
Db.ResultBuffer rb = new Db.ResultBuffer(new Db.TypedValue((Int32)Db.DxfCode.ExtendedDataRegAppName, xName),
new Db.TypedValue((Int32)Db.DxfCode.ExtendedDataInteger16, 391),
new Db.TypedValue((Int32)Db.DxfCode.ExtendedDataReal, 0.125));
dimStyle.XData = rb;
dimStyle.Dimarcsym = 0;
dimStyle.Dimjogang = 90 * Math.PI / 180;
xName = "cad_DSTYLE_DIMJAG";
if (!regTable.Has(xName))
{
regTable.UpgradeOpen();
Db.RegAppTableRecord app = new Db.RegAppTableRecord();
app.Name = xName;
regTable.Add(app);
tr.AddNewlyCreatedDBObject(app, true);
}
rb = new Db.ResultBuffer(
new Db.TypedValue((Int32)Db.DxfCode.ExtendedDataRegAppName, xName),
new Db.TypedValue((Int32)Db.DxfCode.ExtendedDataInteger16, 388),
new Db.TypedValue((Int32)Db.DxfCode.ExtendedDataReal, 1.4995
));
dimStyle.XData = rb;
dimStyle.Dimtxsty = txtStyleId;
dimStyle.Dimclrt = Clr.Color.FromColorIndex(Clr.ColorMethod.ByAci, 256);
dimStyle.Dimtfill = 0;
dimStyle.Dimtfillclr = Clr.Color.FromColorIndex(Clr.ColorMethod.ByAci, 256);
dimStyle.Dimtxt = 3.5;
dimStyle.Dimfrac = 1;
Boolean drawFrameAroundText = false;
dimStyle.Dimtad = 1;
dimStyle.Dimjust = 0;
dimStyle.Dimtxtdirection = true;
dimStyle.Dimgap = 1 * (drawFrameAroundText ? -1 : 1);
dimStyle.Dimtih = false;
dimStyle.Dimtoh = false;
dst.Add(dimStyle);
tr.AddNewlyCreatedDBObject(dimStyle,true);
tr.Commit();
}
}