// Set the Font Style
Acdbobjectid cmaindlg: createtextstyle (cstring fontname, cstring bigfontname, cstring textstylename)
{
ACAD: errorstatus es;
Acapdocument * pdoc = acdocmanager-> curdocument ();
Es = acdocmanager-> lockdocument (pdoc );
If (es! = ACAD: Eok)
{
Acutprintf ("failed to lock the document ");
Return NULL;
}
Acdbobjectid textstyleid;
Acdbtextstyletable textstyletable;
// Textstyletable. getat (" at", textstyleid, false );
Acgitextstyle * textstyle = new acgitextstyle (fontname, bigfontname, 0, 0, 0, adesk: kfalse, adesk: kfalse,
Adesk: kfalse, textstylename); // font name
ToAcDbTextStyle (* TextStyle, textStyleId );
AcDocManager-> unlockDocument (pDoc );
Return textStyleId;
}
// Write text
Void CMainDlg: createText (AcGePoint3d pt, CString strText, double scale, double high/*, CString textCate */)
{
Acad: ErrorStatus es;
AcApDocument * pDoc = acDocManager-> curDocument ();
Es = acDocManager-> lockDocument (pDoc );
If (es! = Acad: eOk)
{
AcutPrintf ("failed to lock the document ");
Return;
}
// If hztxt.shxis not displayed here, only hztxt.txt does not have a question mark?
AcDbObjectId textId = createTextStyle (" style", "", "vm ");
AcDbText * ptext = NULL;
Int nLength = strText. GetLength ();
Char * ch = new char (nLength );
Ch = strText. GetBuffer (0 );
Ptext = new AcDbText (pt, ch, textId, high, 0 );
Ptext-> setWidthFactor (scale );
Ptext-> setColorIndex (0 );
AcDbBlockTable * pblocKTable;
AcdbHostApplicationServices ()-> workingDatabase ()-> getSymbolTable (pblocKTable, AcDb: kForRead );
AcDbBlockTableRecord * pblocKTableRecord;
PblocKTable-> getAt (ACDB_MODEL_SPACE, pblocKTableRecord, AcDb: kForWrite );
PblocKTableRecord-> appendAcDbEntity (textId, ptext );
PblocKTable-> close ();
PblocKTableRecord-> close ();
Ptext-> close ();
AcDocManager-> unlockDocument (pDoc );
}