几何尺寸与公差论坛------致力于产品几何量公差标准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)
-   -   如何在选择的时候,处理esc事件 (http://www.dimcax.com/hust/showthread.php?t=9511)

yang686526 2009-04-21 09:50 AM

如何在选择的时候,处理esc事件
 
如何在选择的时候,处理esc事件
www.dimcax.com
如何在选择的时候,处理esc事件
imports autodesk.autocad.databaseservices
imports autodesk.autocad.geometry
imports autodesk.autocad.runtime
imports autodesk.autocad.colors
imports autodesk.autocad.applicationservices
imports autodesk.autocad.editorinput
public class testedit
dim doc as document = application.documentmanager.mdiactivedocument
dim db as database = hostapplicationservices.workingdatabase
dim ed as editor = application.documentmanager.mdiactivedocument.editor
dim bmove as boolean = false
dim besc as boolean = false
<commandmethod("testsel")> public sub testsel()
addhandler doc.commandcancelled, addressof commandcancelled
'定义过滤条件
dim value1 as typedvalue = new typedvalue(dxfcode.start, "circle,line")
dim value2 as typedvalue = new typedvalue(dxfcode.layername, "0")
dim value3 as typedvalue = new typedvalue(dxfcode.color, "1")
dim values() as typedvalue = {value1, value2, value3}
dim sfilter as new selectionfilter(values)
addhandler doc.commandwillstart, addressof commandwillstart
'定义一个选择集交互类
dim optsel as new promptselectionoptions
optsel.messageforadding = "请选择位于0层的圆和红色的直线"
dim ressel as promptselectionresult = ed.getselection(optsel, sfilter)
if besc = false then
dim sset as selectionset = ressel.value
dim ids as objectid() = sset.getobjectids()
using trans as transaction = db.transactionmanager.starttransaction
'遍历选择集
for each ssetentid as objectid in ids
dim ent as entity = trans.getobject(ssetentid, openmode.forwrite)
ent.color = color.fromcolorindex(colormethod.bycolor, 2)
next ssetentid
trans.commit()
end using
else
ed.writemessage("被中断!")
end if
end sub

sub commandcancelled(byval sender as object, byval e as autodesk.autocad.applicationservices.commandeventargs)
ed.writemessage("esc!!")
besc = true
end sub
end class
代码如何,可按下esc下后,cad程序还是会退出。
求救。


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