- 积分
- 24557
- 明经币
- 个
- 注册时间
- 2004-3-17
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2019-12-28 01:35:58
|
显示全部楼层
在Pycad里试了下,下面的代码是可行的
- _esc = False
- _num = 0
- def pickfirst_added(ed, e):
- if e.Flags == aced.SelectionFlags.PickfirstSet:
- global _esc, _num
- if _esc:
- _esc = False
- _num -= (e.Selection.Count + e.AddedObjects.Count)
- else:
- _num = e.Selection.Count + e.AddedObjects.Count
- ed.WriteMessage("\n%s" % _num)
- def pickfirst_removed(ed, e):
- if e.Flags == aced.SelectionFlags.PickfirstSet:
- global _num
- _num = e.Selection.Count - e.RemovedObjects.Count
- ed.WriteMessage("\n%s" % _num)
- def on_message(sender, e):
- m = e.Message
- if (m.message == 0x0100) and (int(m.wParam) & 65535 == 27):
- global _esc
- _esc = True
- @command()
- def showpickfirstinfo(doc):
- ed = doc.Editor #type: aced.Editor
- ed.SelectionAdded += pickfirst_added
- ed.SelectionRemoved += pickfirst_removed
- acap.Core.Application.PreTranslateMessage += on_message
- @command()
- def unshowpickfirstinfo(doc):
- ed = doc.Editor #type: aced.Editor
- ed.SelectionAdded -= pickfirst_added
- ed.SelectionRemoved -= pickfirst_removed
- acap.Core.Application.PreTranslateMessage -= on_message
复制代码 |
|