Message 1 of 6
Not applicable
10-31-2011
09:02 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm having problems to create "TextStyles" with the sources of AutoCad.
I am using the following methods:
public static ObjectId CreateTexstyle(Configuration conf)
{
Document acDoc = Application.DocumentManager.MdiActiveDocument;
Database acCurDb = acDoc.Database;
using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
{
TextStyleTable textStyleTable = (TextStyleTable)acTrans.GetObject(acCurDb.TextStyleTableId, OpenMode.ForRead);
TextStyleTableRecord textStyleTableRecord = null;
if (textStyleTable.Has(conf.EXTTEXTStyleName) == false)
{
if (textStyleTable.IsWriteEnabled == false)
textStyleTable.UpgradeOpen();
textStyleTableRecord = new TextStyleTableRecord();
textStyleTableRecord.Name = conf.EXTTEXTStyleName;
textStyleTable.Add(textStyleTableRecord);
acTrans.AddNewlyCreatedDBObject(textStyleTableRecord, true);
}
else
{
textStyleTableRecord = acTrans.GetObject(textStyleTable[conf.EXTTEXTStyleName],
OpenMode.ForWrite) as TextStyleTableRecord;
}
textStyleTableRecord.XScale = conf.EXTTEXTFactor;
textStyleTableRecord.TextSize = conf.EXTTEXTSize;
textStyleTableRecord.Font = UpdateTextFont(conf.EXTTEXTFont, conf.EXTTEXTFontItalico, conf.EXTTEXTFontNegrito);
acTrans.Commit();
return textStyleTableRecord.ObjectId;
}
}
public static Autodesk.AutoCAD.GraphicsInterface.FontDescriptor UpdateTextFont(string font, bool italic, bool negrito)
{
return new Autodesk.AutoCAD.GraphicsInterface.FontDescriptor(font, negrito, italic, 0, 0);
}
In the example font = "romans", italic = false end bold = false.
In AutoCad the source is "romans.shx" but is a little different from when it is configured manually.
Programmatically
manually
Note that the text becomes thicker.
And a little change settings window TextStyles. What can be?
Solved! Go to Solution.

