public class StyleCreator
{
[CommandMethod("nts")]
public static void CreateTextStyle()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Transaction tr = db.TransactionManager.StartTransaction();
using ( tr )
{
TextStyleTable styleTable = (TextStyleTable) tr.GetObject(db.TextStyleTableId, OpenMode.ForWrite);
if ( styleTable.Has("BasicText") == false )
{
TextStyleTableRecord textStyle = new TextStyleTableRecord();
textStyle.Name = "BasicText";
textStyle.TextSize = 3.5;
Autodesk.AutoCAD.GraphicsInterface.FontDescriptor fd =
new Autodesk.AutoCAD.GraphicsInterface.FontDescriptor("Simplex", true, false, 0, 0);
textStyle.Font = fd;
textStyle.XScale = 0.7;
styleTable.Add(textStyle);
tr.AddNewlyCreatedDBObject(textStyle, true);
}
if ( styleTable.Has("TitleText") == false )
{
TextStyleTableRecord titleTextStyle = new TextStyleTableRecord();
titleTextStyle.Name = "TitleText";
titleTextStyle.TextSize = 7.5;
Autodesk.AutoCAD.GraphicsInterface.FontDescriptor fd1 =
new Autodesk.AutoCAD.GraphicsInterface.FontDescriptor("Simplex", true, false, 0, 0);
titleTextStyle.Font = fd1;
titleTextStyle.XScale = 0.8;
styleTable.Add(titleTextStyle);
tr.AddNewlyCreatedDBObject(titleTextStyle, true);
}
if ( styleTable.Has("SpecialSigns") == false )
{
TextStyleTableRecord slTextStyle = new TextStyleTableRecord();
slTextStyle.Name = "SpecialSigns";
slTextStyle.TextSize = 3.5;
Autodesk.AutoCAD.GraphicsInterface.FontDescriptor fd1 =
new Autodesk.AutoCAD.GraphicsInterface.FontDescriptor("Times New Roman", false, false, 0,
0);
slTextStyle.Font = fd1;
slTextStyle.XScale = 0.8;
styleTable.Add(slTextStyle);
tr.AddNewlyCreatedDBObject(slTextStyle, true);
}
doc.Editor.Regen();
tr.Commit();
}
}
}