Set text styles and write them to CAD

Source: Internet
Author: User

// 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 );

}
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.