查看单个帖子
旧 2009-04-21, 09:50 AM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 如何在选择的时候,处理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程序还是会退出。
求救。
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)