谢谢这位朋友的关注 问题都已解决,给出代码如下:
//准备开始文字注记 AcDbBlockTable *pBlockTablew; acdbHostApplicationServices()->workingDatabase() ->getSymbolTable(pBlockTablew, AcDb::kForRead); AcDbBlockTableRecord *pBlockTableRecordw; pBlockTablew->getAt(ACDB_MODEL_SPACE, pBlockTableRecordw, AcDb::kForWrite); AcDbDatabase *pDb = acdbHostApplicationServices()->workingDatabase ();
Acad::ErrorStatus es; //打开数据库->块表->块表记录 es = pDb->getBlockTable (pBlockTablew,AcDb::kForRead ); // ERROR HANDLE es = pBlockTablew->getAt (ACDB_MODEL_SPACE,pBlockTableRecordw,AcDb::kForWrite ); 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("HZTXT");//**** if(es != Acad::eOk){ acutPrintf("fail to get the standard text style\n"); } ////////////////////////////////// pBlockTablew->close();//关闭块表 ads_point point; int ret; ret = acedGetPoint(NULL,"\n输入文本标注中心点的坐标:",point); ret= acedCommand(RTSTR, "boundary",RTPOINT ,point, RTSTR, "",0) ; acutPrintf("\n你选的点坐标为 x = %.3f y = %.3f",point[0],point[1]); AcGePoint3d textPosition(point[0], point[1], 0.0); AcGePoint3d atextPosition(point[0], point[1], 0.0); double textHeight = 10; double textWidthFactor = 0.8000; double textRotation = 0.0; AcDbText *pText=new AcDbText(textPosition, textString, AcDbObjectId::kNull, textHeight, textRotation); pText->setHorizontalMode(AcDb::kTextMid); pText->setAlignmentPoint(atextPosition); pText->setColorIndex (1); pText->setTextStyle (idTextStyle); AcDbObjectId idTxt = AcDbObjectId::kNull ; pBlockTableRecordw->appendAcDbEntity(idTxt,pText); pTST->close();//文字样式表 pTSTR->close();//文字样式表记录 ////////////////////////////////////////////////////////////////////// AcDbObjectId textId; pBlockTableRecordw->appendAcDbEntity(textId, pText); //* pBlockTableRecordw->close(); pText->close(); |