![]() |
【转帖】一种快速导入其它文件中块的方法
一种快速导入其它文件中块的方法
www.dimcax.com 一种快速导入其它文件中块的方法 kean的文章,是利用wblockcloneobjects函数来实现的,但代码较多。其实可以使用database类的insert函数可以方便地实现这个功能。 下面的代码导入c:\\test.dwg文件中所有的块: using (transaction trans = db.transactionmanager.starttransaction()) { database curdb = hostapplicationservices.workingdatabase; database sourcedb = new database(true, false); sourcedb.readdwgfile("c:\\test.dwg", system.io.fileshare.read, true, null); sourcedb.closeinput(true); curdb.insert(new matrix3d(), sourcedb, false); trans.commit(); } 复制代码 另:如果你想让c:\\test.dwg文件当作一个块被导入,则curdb.insert(new matrix3d(), sourcedb, false);改成: curdb.insert(“test” sourcedb, false); 请老大指点。 发错贴 [ 老大代码中有点问题,就是 curdb.insert(new matrix3d(), sourcedb, false); 中的new matrix3d()为0矩阵,将得到不正确的变换结果,所以模型空间中的实体看不见。 |
| 所有的时间均为北京时间。 现在的时间是 05:39 AM. |