共享一段mm给我的代码 一起研究!
AcDbDatabase *pDb = acdbHostApplicationServices()->workingDatabase ();
AcDbBlockTable *pBT;
AcDbBlockTableRecord *pBTR;
Acad::ErrorStatus es; //打开数据库->块表->块表记录
es = pDb->getBlockTable (pBT,AcDb::kForRead );
// ERROR HANDLE
es = pBT->getAt (ACDB_MODEL_SPACE,pBTR,AcDb::kForWrite );
//get the standard text style
AcDbTextStyleTable *pTST;
AcDbTextStyleTableRecord *pTSTR;
es = pDb->getTextStyleTable (pTST,AcDb::kForRead );
//文字样式表-〉文字样式表记录-〉打开记录读取
AcDbObjectId idTextStyle;
es = pTST->getAt("Standard",idTextStyle);
es = pTST->getAt("Standard",pTSTR,AcDb::kForWrite );
pTSTR->setFileName("iso");//****
if(es != Acad::eOk){
acutPrintf("fail to get the standard text style\n");
}
//es = acdbOpenObject(pEnt,idTextStyle,AcDb::kForRead );
AcDbMText *pText = new AcDbMText();
pText->setLocation (AcGePoint3d(10,10,0));
pText->setTextStyle (idTextStyle);
pText->setRotation (0.5);
pText->setContents ("\\T1.2;this is only simple char");
pText->setColorIndex (1);
AcDbObjectId idTxt = AcDbObjectId::kNull ;
pBTR->appendAcDbEntity(idTxt,pText);
pText->close();//文本对象
pBTR->close();//块表记录
pBT->close();//块表
pTST->close();//文字样式表
pTSTR->close();//文字样式表记录
|