![]() |
【转帖】如何显示文字
如何显示文字
如何显示文字 此主题相关图片如下: 请问,在程序里如何写,才能让一段文字显示在下面图片的那个小框里面呢?或者是在cad下弹出个对话框,输入一段文本后,我怎么把问题提取到图片中的那个小框中呢?请给点方面的事例,十分感谢. 拾取两个角点,求出中心点,然后添加文字,用中心对齐方式。 那用程序怎么才能把文字写到cad上呢?能不能给点参考啊? acdbtext 我也有这个问题。不知道怎么用acdbtext (); 那位大虾能赐教acdbtext ()的使用问题, 谢谢!! 源码没头文件,及入口函数,这些自己定义吧, void text() { acdbblocktable* pblocktable; acdbhostapplicationservices()->workingdatabase() ->getsymboltable(pblocktable,acdb::kforread); acdbblocktablerecord* pblocktablerecord; pblocktable->getat(acdb_model_space,pblocktablerecord, acdb::kforwrite); pblocktable->close(); double ptt[4][3]= { {0,0,0}, {420,0,0}, {420,297,0}, {0,297,0}, }; acgepoint3d pt(ptt[0][0]+100,ptt[0][1]+100,ptt[0][2]); acdbtext* ptext=new acdbtext; ptext->sethorizontalmode(acdb::ktextright); ptext->setalignmentpoint(pt); ptext->settextstring("100"); ptext->settextstyle(acdbobjectid::knull); ptext->setheight(30); ptext->setrotation(0); acdbobjectid ptextid; pblocktablerecord->appendacdbentity(ptextid,ptext); pblocktablerecord->close(); ptext->close(); } 没头文件及入口函数,自己定义。 acdbdatabase *pdb = new acdbdatabase; acdbblocktable *pblocktable; pdb->getsymboltable(pblocktable, acdb::kforread); acdbblocktablerecord *pblocktablerecord; pblocktable->getat(acdb_model_space, pblocktablerecord, acdb::kforwrite); pblocktable->close(); acgepoint3d textposition(120.0, 80.0, 0.0); acgepoint3d atextposition(130.0, 80.0, 0.0); char textstring[512] = "auto create drawing"; double textheight = 5.5296; double textwidthfactor = 0.8000; double textthickness = 0.0; double textrotation = 0.0; acdbtext *ptext=new acdbtext(textposition, textstring, acdbobjectid::knull, textheight, textrotation); ptext->sethorizontalmode(acdb::ktextmid);// ptext->setalignmentpoint(atextposition); // acdbobjectid textid; pblocktablerecord->appendacdbentity(textid, ptext); pblocktablerecord->close(); ptext->close(); pdb->saveas("测试文件.dwg"); delete pdb; 请问大家如何才能使"测试文件.dwg"中的文字能够正确设置?一打开文件,文字现在仍然是左对齐,只不过有中间对齐点,并且属性框中也这么显示。搞不定了,恳请大家帮帮。 qq:19154480 msn:freejustinji@hotmail.com e-mail:justin3@citiz.net 谢谢xd空间的binbin和王咣生版主,问题搞定了。 (没头文件及入口函数,自己定义。) 功能:实现在后台数据库中正确添加文字,并且设置文字属性。关键是把后台数据库设置当前,最后设置回去。 acdbdatabase *polddb = acdbhostapplicationservices()->workingdatabase(); acdbdatabase *pdb = new acdbdatabase; acdbhostapplicationservices()->setworkingdatabase(pdb); acdbblocktable *pblocktable; acdbhostapplicationservices()->workingdatabase()->getsymboltable(pblocktable, acdb::kforread); acdbblocktablerecord *pblocktablerecord; pblocktable->getat(acdb_model_space, pblocktablerecord, acdb::kforwrite); pblocktable->close(); acgepoint3d textposition(120.0, 80.0, 0.0); acgepoint3d atextposition(130.0, 80.0, 0.0); char textstring[512] = "auto create drawing"; 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; pblocktablerecord->appendacdbentity(textid, ptext); pblocktablerecord->close(); ptext->close(); pdb->saveas("测试文件.dwg"); acdbhostapplicationservices()->setworkingdatabase(polddb); delete pdb; 请问各位大侠,如何可以动态确定文字长度?因为希望可以把超出范围的文字,通过设置大小,或者比例因子来缩放回去。 我用了9楼的代码,我想9楼的代码的作用应该是在一个打开的dwg文件中,在设定的位置加上文字"auto create drawing".最后是保存到"测试文件.dwg"这个文件中吧. 我运行的结果是:原来的那个dwg文件没有加上"auto create drawing",而"文件名.dwg"这个文件中只显示"auto create drawing",却没有其他任何图形或者文字.所以不知道问题出在哪里? |
| 所有的时间均为北京时间。 现在的时间是 03:13 AM. |