『已解决』利用wipeout对象来生成遮罩 - 精华帖集合
www.dimcax.com
『已解决』利用wipeout对象来生成遮罩
qq群里的志刚提出的一个问题。他给的代码是这样的:
[commandmethod("wipe")]
public void wipe()
{
wipeout wpo = new wipeout();
clipboundarytype cbt = clipboundarytype.poly;
point2dcollection pnts = new point2dcollection();
pnts.add(new point2d(100, 100));
pnts.add(new point2d(800, 100));
pnts.add(new point2d(800, 600));
pnts.add(new point2d(100, 600));
pnts.add(new point2d(100, 100));
wpo.setclipboundary(cbt, pnts);
wpo.setclipboundarytowholeimage();
tools.addentity(wpo);
}
复制代码
结果生成的是一个长宽均为单位长度的矩形wipeout对象,这个显然是不对的。刚开始还以为可能是坐标转换的问题,但实际试下来也不是的。最后看了一下wipeout对象的函数,发现只有一个setfrom,难道是它? 赶紧改写了一下程序,如下:
[commandmethod("wipe")]
public void wipe()
{
wipeout wpo = new wipeout();
//clipboundarytype cbt = clipboundarytype.poly;
point2dcollection pnts = new point2dcollection();
pnts.add(new point2d(100, 100));
pnts.add(new point2d(800, 100));
pnts.add(new point2d(800, 600));
pnts.add(new point2d(100, 600));
pnts.add(new point2d(100, 100));
wpo.setfrom(pnts, vector3d.zaxis);
//wpo.setclipboundary(cbt, pnts);
//wpo.setclipboundarytowholeimage();
tools.addentity(wpo);
}
复制代码
程序运行下来完全正确,得到了所需要的wipeout。要注意的是:在objectarx的.net参考文档中,是没有wipeout对象的,可能是写帮助的时候没有写进去(因为wipeout是08版本中才有的)。但它是确实存在的 。 程序的运行结果(在wipe命令之前画些东西,这样wipeout才会遮住下面的东西):
才鸟牛人,这个问题都替我给解决了。了
请问一下tools.addentity(wpo); 这个tools 是什么对象 怎么获得呢? 一般增加实体 是通过modelspace.add.....来增加的? !!
原帖由 gisren 于 2008-1-6 09:11 pm 发表 请问一下tools.addentity(wpo); 这个tools 是什么对象 怎么获得呢? 一般增加实体 是通过modelspace.add.....来增加的? !!
tools 是dotnetarx中的一个类,关于dotnetarx请看dotnetarx区的介绍
c#最适合开发autocad,因为它拥有vb容易的特点,却具有vc++的强大功能。
[commandmethod("wipe")] public void wipe() { wipeout wpo = new wipeout(); //clipboundarytype cbt = clipboundarytype.poly; point2dcollection pnts = new point2dcollection(); pnts.add(new point2d(100, 100)); pnts.add(new point2d(800, 100)); pnts.add(new point2d(800, 600)); pnts.add(new point2d(100, 600)); pnts.add(new point2d(100, 100)); wpo.setfrom(pnts, vector3d.zaxis); //wpo.setclipboundary(cbt, pnts); //wpo.setclipboundarytowholeimage(); tools.addentity(wpo); } 采用上面的方法 在cad2008中 使用 cad常出现异常退出请问 可能是什么原因?!
在autocad2009也是一样,会出现异常
database db = application.documentmanager.mdiactivedocument.database wipeout wo = new wipeout(); point2dcollection pnts = new point2dcollection(); pnts.add(new point2d(100, 100)); pnts.add(new point2d(800, 100)); pnts.add(new point2d(800, 600)); pnts.add(new point2d(100, 600)); pnts.add(new point2d(100, 100)); wo.setdatabasedefaults(db); wo.setfrom(pnts, vector3d.zaxis); 试一下这样能解决不? [ ]
一样不行,在获取对象特性时,cad就是马上崩溃死掉