![]() |
【转帖】请问 在c#下怎样实现块插入,有这方面的例子吗?期待中!!
请问 在c#下怎样实现块插入,有这方面的例子吗?期待中!!
www.dimcax.com 请问 在c#下怎样实现块插入,有这方面的例子吗?期待中!! 请问 在c#下怎样实现块插入,有这方面的例子吗?期待中!! [s:3] 请大家试一试下面的例子: public class testinsert { [commandmethod("testinsert")] static public void doit() { document doc = application.documentmanager.mdiactivedocument; editor ed = doc.editor; promptresult res = ed.getstring("give me a file to insert"); if (res.status != promptstatus.ok) return; string fname = res.stringresult; if (!file.exists(fname)) fname = hostapplicationservices.current.findfile(fname, doc.database, findfilehint.default); using (database db = new database(false, false)) { //read drawing db.readdwgfile(fname, fileshare.read, true, null); using (transaction t = doc.transactionmanager.starttransaction()) { //insert it as a new block objectid idbtr = doc.database.insert("test", db, false); //create a ref to the block blocktable bt = (blocktable)t.getobject(doc.database.blocktableid, openmode.forread); blocktablerecord btr = (blocktablerecord)t.getobject(bt[blocktablerecord.modelspace], openmode.forwrite); using (blockreference bref = new blockreference(point3d.origin, idbtr)) { btr.appendentity(bref); t.addnewlycreateddbobject(bref, true); } t.commit(); } } } } 提供一个思路 1.获得块表 2.获得模型空间 3.如果块表中有该块,返回该块id 4.否则,新建一块表记录,设置相关属性,添加相关实体。 5.将该块添加入模型空间 6.提交事务,删除事务对象。 大致是这么个路子。 |
所有的时间均为北京时间。 现在的时间是 02:11 AM. |