![]() |
【转帖】关于进行文本标注
关于进行文本标注
关于进行文本标注 新建图层“选址标注”;当鼠标点击屏幕位置(鼠标事件的响应?)时在点击位置标注内容:“建设项目选址意见书[5字]” 哪位高手帮忙 回个话 做不了我可就完蛋了 现在已经完成了新建图层: void createnewlayer(const cstring layername, const int color) { acdblayertable *playertbl; acdbhostapplicationservices()->workingdatabase() ->getsymboltable(playertbl, acdb::kforwrite); //获得当前层表以便写入 if (!playertbl->has(layername)) { acdblayertablerecord *playertblrcd = new acdblayertablerecord; playertblrcd->setname(layername); playertblrcd->setisfrozen(0);// layer to thawed解冻图层 playertblrcd->setisoff(0); // layer to on 打开图层 playertblrcd->setvpdflt(0); // viewport default视口默认值 playertblrcd->setislocked(0);// un-locked 解锁图层 accmcolor color1; color1.setcolorindex(color); // set color to color playertblrcd->setcolor(color1); acdblinetypetable *plinetypetbl; acdbobjectid ltid; acdbhostapplicationservices()->workingdatabase() ->getsymboltable(plinetypetbl, acdb::kforread); if ((plinetypetbl->getat("continuous", ltid)) != acad::eok) { acutprintf("\nunable to find continuous" " linetype. using dashed"); plinetypetbl->getat("continuous", ltid); } plinetypetbl->close();//设置线型 playertblrcd->setlinetypeobjectid(ltid); playertbl->add(playertblrcd); //将层表记录添加到层表中! playertblrcd->close();//关闭层表记录 playertbl->close();//关闭层表 } else { playertbl->close(); acutprintf("\n图层已经存在!"); } /* acdb::lineweight lw; //设置层的线宽 lw = acdb::klnwt080; //value:80 playertablerecord->setlineweight(lw); */ } 朋友给了段带码很管用,但是遇到两个问题: 1。文章是中文的时候出现乱码? 2。不知道如何设坐标点(下面的代码是坐标点已知的),使得在鼠标点击屏幕位置(鼠标事件的响应?)时的点击位置标注内容? void addtext( char textstring[512]) { acdbblocktable *pblocktablew; acdbhostapplicationservices()->workingdatabase()->getsymboltable(pblocktablew, acdb::kforread); acdbblocktablerecord *pblocktablerecordw; pblocktablew->getat(acdb_model_space, pblocktablerecordw, acdb::kforwrite); pblocktablew->close(); acgepoint3d textposition(10.0, 10.0, 0.0); acgepoint3d atextposition(20.0, 10.0, 0.0); //char textstring[512] = "建设项目选址意见书[5字] 号红线附图"; double textheight = 5.5296; 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); acdbobjectid textid; pblocktablerecordw->appendacdbentity(textid, ptext); pblocktablerecordw->close(); ptext->close(); } 我也想知道,帮你顶 1。文章是中文的时候出现乱码? >设置文本的样式 //www.dimcax.com cad一次开发的家园 ----------黄毛丫丫 acdbtextstyletablerecord* pstylenew= new acdbtextstyletablerecord; pstylenew->setname((lpctstr)strname); pstylenew->setfilename("gbenor.shx"); pstylenew->setbigfontfilename("gbcbig.shx");//支持中文 pstylenew->setxscale(1.0); //www.dimcax.com cad一次开发的家园 ----------黄毛丫丫 谢谢这位朋友的关注 问题都已解决,给出代码如下: //准备开始文字注记 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(); |
| 所有的时间均为北京时间。 现在的时间是 04:39 PM. |