[CommandMethod("TestText")]
static public void TestDbText()
// CodeHimBelongaKbub@TheSwamp © Dec 2008
{
Database db = HostApplicationServices.WorkingDatabase;
string txtStr = "This is a DbText string.";
string txtStyleName = "kbubsComicTextStyle";
string txtFileName = "Comic.ttf";
using (Transaction tr = db.TransactionManager.StartTransaction())
{
BlockTableRecord currentSpaceBtr = tr.GetObject(db.CurrentSpaceId,
OpenMode.ForWrite) as BlockTableRecord;
DBText textObj
= new DBText
(); textObj.TextString = txtStr;
textObj.Height = 500;
textObj
.Position = new Point3d
(0,
0,
0);
textObj.HorizontalMode = TextHorizontalMode.TextMid;
textObj.AlignmentPoint = textObj.Position;
TextStyleTable txtTbl = tr.GetObject(db.TextStyleTableId,
OpenMode.ForRead) as TextStyleTable;
if (!txtTbl.Has(txtStyleName))
{
AssertOrMakeTextStyle(txtStyleName, txtFileName);
}
TextStyleTableRecord txtTbr = tr.GetObject(txtTbl[txtStyleName],
OpenMode.ForRead) as TextStyleTableRecord;
if (txtTbr != null)
{
textObj.TextStyle = txtTbr.ObjectId;
}
currentSpaceBtr.AppendEntity(textObj);
tr.AddNewlyCreatedDBObject(textObj, true);
tr.Commit();
}
}