关于进行文本标注
<P><FONT face=宋体>新建图层“选址标注”;当鼠标点击屏幕位置(鼠标事件的响应?)时在点击位置标注内容:“建设项目选址意见书”</FONT></P><P><FONT face=宋体>哪位高手帮忙 回个话 做不了我可就完蛋了</FONT></P>
<P>现在已经完成了新建图层:</P>
<P>void createNewLayer(const CString LayerName, const int color)<BR>{ AcDbLayerTable *pLayerTbl;<BR> acdbHostApplicationServices()->workingDatabase()<BR> ->getSymbolTable(pLayerTbl, AcDb::kForWrite);<BR> //获得当前层表以便写入<BR> if (!pLayerTbl->has(LayerName)) {<BR> AcDbLayerTableRecord *pLayerTblRcd<BR> = new AcDbLayerTableRecord;<BR> pLayerTblRcd->setName(LayerName);<BR> pLayerTblRcd->setIsFrozen(0);// layer to THAWED解冻图层<BR> pLayerTblRcd->setIsOff(0); // layer to ON 打开图层<BR> pLayerTblRcd->setVPDFLT(0); // viewport default视口默认值<BR> pLayerTblRcd->setIsLocked(0);// un-locked 解锁图层</P>
<P> AcCmColor color1;<BR> color1.setColorIndex(color); // set color to color<BR> pLayerTblRcd->setColor(color1);</P>
<P><BR> AcDbLinetypeTable *pLinetypeTbl;<BR> AcDbObjectId ltId;<BR> acdbHostApplicationServices()->workingDatabase()<BR> ->getSymbolTable(pLinetypeTbl, AcDb::kForRead);<BR> if ((pLinetypeTbl->getAt("CONTINUOUS", ltId))<BR> != Acad::eOk)<BR> {<BR> acutPrintf("\nUnable to find CONTINUOUS"<BR> " linetype. Using DASHED");<BR> pLinetypeTbl->getAt("CONTINUOUS", ltId);<BR> }<BR> pLinetypeTbl->close();//设置线型</P>
<P> pLayerTblRcd->setLinetypeObjectId(ltId);</P>
<P><BR> pLayerTbl->add(pLayerTblRcd); //将层表记录添加到层表中!<BR> pLayerTblRcd->close();//关闭层表记录<BR> pLayerTbl->close();//关闭层表<BR> } else {<BR> pLayerTbl->close();<BR> acutPrintf("\n图层已经存在!");<BR> }<BR> /*<BR> AcDb::LineWeight lw; //设置层的线宽<BR> lw = AcDb::kLnWt080; //value:80<BR> pLayerTableRecord->setLineWeight(lw);<BR> */</P>
<P>}</P>
<P><FONT face=宋体><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></FONT> </P> <P>朋友给了段带码很管用,但是遇到两个问题:</P>
<P>1。文章是中文的时候出现乱码?</P>
<P>2。不知道如何设坐标点(下面的代码是坐标点已知的),使得在鼠标点击屏幕位置(鼠标事件的响应?)时的点击位置标注内容?</P>
<P>void addtext( char textString)<BR>{<BR> <BR> AcDbBlockTable *pBlockTablew;<BR> acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlockTablew, AcDb::kForRead);<BR> AcDbBlockTableRecord *pBlockTableRecordw;<BR> pBlockTablew->getAt(ACDB_MODEL_SPACE, pBlockTableRecordw, AcDb::kForWrite);<BR> pBlockTablew->close();</P>
<P><BR> AcGePoint3d textPosition(10.0, 10.0, 0.0);<BR> AcGePoint3d atextPosition(20.0, 10.0, 0.0);<BR> //char textString = "建设项目选址意见书 号红线附图";<BR> double textHeight = 5.5296;<BR> double textWidthFactor = 0.8000;<BR> double textRotation = 0.0;</P>
<P> AcDbText *pText=new AcDbText(textPosition, textString, AcDbObjectId::kNull, textHeight, textRotation);<BR> pText->setHorizontalMode(AcDb::kTextMid);<BR> pText->setAlignmentPoint(atextPosition); </P>
<P> AcDbObjectId textId;<BR> pBlockTableRecordw->appendAcDbEntity(textId, pText); <BR> pBlockTableRecordw->close();<BR> pText->close();<BR>}</P> <P>我也想知道,帮你顶</P> <P>1。文章是中文的时候出现乱码?</P>
<P>>设置文本的样式</P>
<P> </P> <P> </P>
<P> </P>
<P>AcDbTextStyleTableRecord* pStyleNew= new AcDbTextStyleTableRecord;</P>
<P>pStyleNew->setName((LPCTSTR)strName);<BR> pStyleNew->setFileName("gbenor.shx");<BR> pStyleNew->setBigFontFileName("gbcbig.shx");//支持中文<BR> pStyleNew->setXScale(1.0);</P> <P>谢谢这位朋友的关注 问题都已解决,给出代码如下:</P>
<P> </P>
<P> //准备开始文字注记<BR> AcDbBlockTable *pBlockTablew;<BR> acdbHostApplicationServices()->workingDatabase()<BR> ->getSymbolTable(pBlockTablew, AcDb::kForRead);<BR> AcDbBlockTableRecord *pBlockTableRecordw;<BR> pBlockTablew->getAt(ACDB_MODEL_SPACE, <BR> pBlockTableRecordw, AcDb::kForWrite);<BR> AcDbDatabase *pDb = acdbHostApplicationServices()->workingDatabase ();</P>
<P>Acad::ErrorStatus es; //打开数据库->块表->块表记录 <BR> es = pDb->getBlockTable (pBlockTablew,AcDb::kForRead );<BR> // ERROR HANDLE<BR> es = pBlockTablew->getAt (ACDB_MODEL_SPACE,pBlockTableRecordw,AcDb::kForWrite );<BR> AcDbTextStyleTable *pTST;<BR> AcDbTextStyleTableRecord *pTSTR;<BR> es = pDb->getTextStyleTable (pTST,AcDb::kForRead );<BR> //文字样式表-〉文字样式表记录-〉打开记录读取<BR> AcDbObjectId idTextStyle;<BR> es = pTST->getAt("Standard",idTextStyle);<BR> es = pTST->getAt("Standard",pTSTR,AcDb::kForWrite );<BR> pTSTR->setFileName("HZTXT");//**** <BR> if(es != Acad::eOk){ <BR> acutPrintf("fail to get the standard text style\n");<BR> }<BR> //////////////////////////////////<BR> pBlockTablew->close();//关闭块表<BR> <BR> ads_point point;<BR> int ret; <BR> ret = acedGetPoint(NULL,"\n输入文本标注中心点的坐标:",point);<BR> ret= acedCommand(RTSTR, "boundary",RTPOINT ,point, RTSTR, "",0) ;<BR> acutPrintf("\n你选的点坐标为 x = %.3f y = %.3f",point,point);<BR> AcGePoint3d textPosition(point, point, 0.0);<BR> AcGePoint3d atextPosition(point, point, 0.0);<BR> <BR> double textHeight = 10;<BR> double textWidthFactor = 0.8000;<BR> double textRotation = 0.0;<BR> <BR> AcDbText *pText=new AcDbText(textPosition, textString, AcDbObjectId::kNull, textHeight, textRotation);<BR> pText->setHorizontalMode(AcDb::kTextMid);<BR> pText->setAlignmentPoint(atextPosition);<BR> pText->setColorIndex (1); <BR> <BR> pText->setTextStyle (idTextStyle);<BR> <BR> AcDbObjectId idTxt = AcDbObjectId::kNull ;<BR> pBlockTableRecordw->appendAcDbEntity(idTxt,pText);<BR> <BR> pTST->close();//文字样式表<BR> pTSTR->close();//文字样式表记录<BR> //////////////////////////////////////////////////////////////////////<BR> <BR> AcDbObjectId textId;<BR> pBlockTableRecordw->appendAcDbEntity(textId, pText); //*<BR> pBlockTableRecordw->close();<BR> pText->close();</P> 我的问题依旧 我的问题依旧
页:
[1]