![]() |
【转帖】clone文字后,为什么cad不显示?
clone文字后,为什么cad不显示?
www.dimcax.com clone文字后,为什么cad不显示? dim db as database = hostapplicationservices.workingdatabase dim trans as transaction = db.transactionmanager.starttransaction() dim bt as blocktable = trans.getobject(db.blocktableid, openmode.forread) dim btr as blocktablerecord = trans.getobject(bt(blocktablerecord.modelspace), openmode.forwrite) dim sstext as dbtext sstext = stext.clone() sstext.position = pres.value sstext.textstring = format(sum, make_format(jd)) btr.appendentity(sstext) trans.addnewlycreateddbobject(sstext, true) trans.commit() trans.dispose() 复制代码 其中stext是一个已有的dbtext 运行结束后cad中不能显示,不知道为什么?请各位大侠指教! using system; using system.collections.generic; using system.linq; using system.text; using autodesk.autocad.applicationservices; using autodesk.autocad.databaseservices; using autodesk.autocad.editorinput; using autodesk.autocad.geometry; using autodesk.autocad.runtime; using acadapp = autodesk.autocad.applicationservices.application; [assembly: commandclass(typeof(acad namespace acad static public void test01() { database db = hostapplicationservices.workingdatabase; editor ed = acadapp.documentmanager.mdiactivedocument.editor; promptentityoptions prentopts = new promptentityoptions("\nselect a text"); prentopts.setrejectmessage("\nselected entity must be of type text"); prentopts.addallowedclass(typeof(dbtext), false); promptentityresult prentres = ed.getentity(prentopts); if (prentres.status != promptstatus.ok) return ; ed.writemessage("\n masterid is : " + prentres.objectid.tostring()); objectid slaveid = objectid.null; using (transaction tr = db.transactionmanager.starttransaction()) { dbtext master = tr.getobject(prentres.objectid, openmode.forread, true) as dbtext; dbtext slave = master.clone() as dbtext; blocktable bt = tr.getobject(db.blocktableid, openmode.forread, false) as blocktable; blocktablerecord btrmodelspace = tr.getobject(bt[blocktablerecord.modelspace], openmode.forwrite, false) as blocktablerecord; point3d mpos = master.position; vector3d offset = new vector3d(0.0, 50.0, 0.0); point3d spos = mpos.add(offset); slave.position = spos; slaveid = btrmodelspace.appendentity(slave); tr.addnewlycreateddbobject(slave, true); tr.commit(); } ed.writemessage("\n slaveid is : " + slaveid.tostring()); } } } 复制代码 c#最适合开发autocad,因为它拥有vb容易的特点,却具有vc++的强大功能。 上面的代码转载自 但好像老外提到了,如果你要复制实体的话,还是用database.deepcloneobjects(),比较好 c#最适合开发autocad,因为它拥有vb容易的特点,却具有vc++的强大功能。 |
所有的时间均为北京时间。 现在的时间是 09:18 AM. |