songzhi 发表于 2005-12-14 21:46:00

GetEntity 与 GetPoint

使用GetPoint的时候可以输入关键字,而在使用GetEntity的时候不行。帮助文件也是这样讲的,但我想实现类似的功能(我有个程序如果能用上这种方法可以大大提高效率),请高人指点!

wyj7485 发表于 2005-12-15 08:15:00

Sub Mccad_InitializeUserInput()
    ' 该示例提示用户选择对象,并通过
    ' InitializeUserInput 方法定义关键字列表,
    ' 用户要以用它来输入关键字。
   
    On Error Resume Next
   
    ' 定义有效的关键字
    Dim keywordList As String
    keywordList = "S E"
   
    ' 调用 InitializeUserInput 初始化关键字
    ThisDrawing.Utility.InitializeUserInput 0, keywordList
   
    ' 获得用户输入
    Dim Pnt As Variant
    Dim ent As AcadEntity
   ThisDrawing.Utility.GetEntity ent, Pnt, "选择对象[设置(S)/删除(E)]: "
    If Err Then
         If StrComp(Err.Number, -2145320928, 1) = 0 Then
         ' 当输入关键字时
             Dim inputString As String
             Err.Clear
             inputString = ThisDrawing.Utility.GetInput
             MsgBox "输入的关键字是: " & inputString
         Else
             MsgBox "选择对象出错: " & Err.Description
             Err.Clear
         End If
    Else
      ' 显示用户选定的对象类型
      MsgBox "你选定的对象类型为: " & ent.ObjectName, , "乐筑天下VBA示例:GetEntity及InitializeUserInput方法"
    End If
End Sub

songzhi 发表于 2005-12-15 20:28:00

谢谢!
我以前也是这么编的,不知道怎么的就是不行,我再试试看吧!
页: [1]
查看完整版本: GetEntity 与 GetPoint