明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1700|回复: 5

[命令] GetKeywords方法默认值问题

[复制链接]
发表于 2011-1-27 14:19 | 显示全部楼层 |阅读模式
下面的命令输入一个关键字:

  1.     <CommandMethod("TT")> Public Sub TT()
  2.         Dim doc As Document = Application.DocumentManager.MdiActiveDocument
  3.         Dim ed As Editor = doc.Editor
  4.         Dim msg As String = "指定偏移距离或 [通过(T)/删除(E)/图层(L)]"
  5.         Dim keywords As String = "Through Erase Layer"
  6.         Dim opt As New PromptKeywordOptions(vbLf & msg, keywords)
  7.         opt.Keywords.Default = "Through"
  8.         opt.AppendKeywordsToMessage = True
  9.         opt.AllowNone = True
  10.         Dim res As PromptResult = ed.GetKeywords(opt)
  11.         If res.Status <> PromptStatus.OK Then
  12.             Return
  13.         End If
  14.         ed.WriteMessage(vbLf & "res.StringResult={0}", res.StringResult)
  15.     End Sub
对比一下该命令和AutoCAD offset命令的提示效果:
命令: _offset
指定偏移距离或 [通过(T)/删除(E)/图层(L)] <通过>:
命令: tt
指定偏移距离或 [通过(T)/删除(E)/图层(L)] <通过(T)>:

怎样实现offset命令那样的默认值提示,即不提示括号中的内容?

发表于 2011-1-27 14:45 | 显示全部楼层
似乎应该用这个?
Editor.GetDistance Method (PromptDistanceOptions)
 楼主| 发表于 2011-1-27 16:39 | 显示全部楼层
前面例子仅仅用于说明问题。
类似问题,GetKeywords如何解决?
发表于 2011-1-27 18:02 | 显示全部楼层
我就是这个意思,:)
你要的效果GetKeywords是实现不了的,只能用其他的Get,并加Keywords
 楼主| 发表于 2011-1-28 10:47 | 显示全部楼层
添加下面代码,问题解决,估计AutoCAD东亚语言版本也是这么做的。:)
  1.         Dim strDisplay As String = opt.Keywords.GetDisplayString(False)
  2.         Dim i = strDisplay.IndexOf("<")
  3.         Dim j = strDisplay.IndexOf(">")
  4.         If i >= 0 And j >= 0 Then
  5.             Dim strDefault As String = strDisplay.Substring(i, j - i + 1)
  6.             i = strDisplay.IndexOf("(")
  7.             j = strDisplay.IndexOf(")")
  8.             strDefault = strDefault.Remove(i, j - i + 1)
  9.             opt.Message = vbLf & msg & " " & strDefault
  10.             opt.AppendKeywordsToMessage = False
  11.         End If

评分

参与人数 1明经币 +3 收起 理由
雪山飞狐_lzh + 3

查看全部评分

发表于 2011-1-28 15:15 | 显示全部楼层
有时间看看这方面的东东,:)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-4-28 02:55 , Processed in 0.291391 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表