几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   ObjectARX(VB.NET/C#) (http://www.dimcax.com/hust/forumdisplay.php?f=176)
-   -   【转帖】一种快速导入其它文件中块的方法 (http://www.dimcax.com/hust/showthread.php?t=9251)

yang686526 2009-04-20 05:40 PM

【转帖】一种快速导入其它文件中块的方法
 
一种快速导入其它文件中块的方法
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矩阵,将得到不正确的变换结果,所以模型空间中的实体看不见。


所有的时间均为北京时间。 现在的时间是 02:26 PM.