![]() |
动态生成文本
动态生成文本
www.dimcax.com 动态生成文本 using 。。。 public class mywzzj : drawjig { private static double blc; private string strx; private dbtext txtobj; private static point3d oldpt, newpt; protected override samplerstatus sampler(jigprompts prompts) { jigpromptpointoptions ptoptions = new jigpromptpointoptions("\n输入插入点"); ptoptions.userinputcontrols = userinputcontrols.nullresponseaccepted; promptpointresult ptresult = prompts.acquirepoint(ptoptions); if (ptresult.status != promptstatus.ok) return samplerstatus.cancel; newpt = ptresult.value; if (newpt != oldpt) { vector3d v3 = oldpt.getvectorto(newpt); txtobj.transformby(matrix3d.displacement(v3)); oldpt = newpt; } else return samplerstatus.nochange; return samplerstatus.ok; } protected override bool worlddraw(worlddraw draw) { draw.geometry.draw(txtobj); return true; } [commandmethod("zjwz")] public void yzawzzj() { //注记文字 //设置图层“zj” //设置颜色随层 promptstringoptions soptions = new promptstringoptions("\n输入注记文本"); soptions.allowspaces = true; promptresult sres = acadapp.documentmanager.mdiactivedocument.editor.getstring(soptions); if (sres.status != promptstatus.ok) return; string resultstr = sres.stringresult; if (resultstr.length < 1) return; promptdoubleoptions doptions = new promptdoubleoptions("\n输入文字高度"); doptions.allowarbitraryinput = false; doptions.allownegative = false; doptions.allowzero = false; doptions.allownone = true; doptions.usedefaultvalue = true; doptions.defaultvalue = 2.4; promptdoubleresult dres = acadapp.documentmanager.mdiactivedocument.editor.getdouble(doptions); if (dres.status != promptstatus.ok) return; getblc(); txtobj = new dbtext(); txtobj.height = blc * dres.value; txtobj.widthfactor = 0.8; txtobj.textstring = resultstr; //txtobj.horizontalmode = texthorizontalmode.textmid; txtobj.position = new point3d(0, 0, 0); txtobj.layer = "zj"; txtobj.colorindex = 256; txtobj.textstyle = hostapplicationservices.workingdatabase.textstyle; oldpt = txtobj.position; promptresult myresult = acadapp.documentmanager.mdiactivedocument.editor.drag(this); if (myresult.status != promptstatus.ok) { txtobj.dispose(); return; } database db = hostapplicationservices.workingdatabase; transaction trans = db.transactionmanager.starttransaction() ; try { blocktable bt = (blocktable)trans.getobject(db.blocktableid, openmode.forread); blocktablerecord btr = (blocktablerecord)trans.getobject(db.currentspaceid, openmode.forwrite); btr.appendentity(txtobj); trans.addnewlycreateddbobject(txtobj, true); } catch { txtobj.dispose(); } finally { trans.commit(); trans.dispose(); } } } [ 学习 学习 getblc() 这个是什么? getblc 是取得图形比例尺的函数 学如逆水行舟,不进则退! |
所有的时间均为北京时间。 现在的时间是 08:04 AM. |