C : VBA  February 04, 2006

●コマンドラインでオプションの表示

Getpoint メソッドを利用して
座標 または オプション文字を取得するには

InitializeUserInput メソッドで キーワードを作成
GetInput メソッドで入力された文字を取得します。

参考:AutoCADHelp ActiveX/VBA 開発者用ガイド
「GetInput メソッド, GetInteger メソッドと使用」

 

'///////////////////////////////////////////////////////////////////////

Sub pointTest()

Dim pntA As Variant
Dim tempPnt(2) As Double
Dim initStr As String
Dim keyStr As String
Dim promptStr As String

    '点の定義
    tempPnt(0) = 10#: tempPnt(1) = 10#: tempPnt(2) = 10#

    'InitializeUserInputのキーワード
    keyStr = "U C"
   
    'コマンドプロンプト
    promptStr = "next point [元に戻す(U)/閉じる(C)]: "
   
    '点の取得
    pntA = anGetPnt(initStr, tempPnt, keyStr, promptStr)
   
    If IsEmpty(pntA) Then
        MsgBox initStr
    Else
        MsgBox pntA(0) & "," & pntA(1) & "," & pntA(2)
    End If
   
End Sub

'-----------------------------------------------------------

Function anGetPnt(ByRef gWord As String, beforPnt As Variant, keyWordStr As String, mesageStr As String) As Variant

On Error Resume Next

    'InitializeUserInput
    ThisDrawing.Utility.InitializeUserInput 2, keyWordStr
   
    '参照点の判別
    If IsEmpty(beforPnt) Then
    anGetPnt = ThisDrawing.Utility.GetPoint(, mesageStr)
    Else
    anGetPnt = ThisDrawing.Utility.GetPoint(beforPnt, mesageStr)
    End If
   
    If Err Then
        Select Case Err.Number
        Case -2147352567  'Esc
            gWord = "Esc"
           
        Case -2145320928  ' Put Keyboard
            '文字の取得
            gWord = ThisDrawing.Utility.GetInput
            If gWord = "" Then
                gWord = "Enter"
            End If
           
        Case Else
        End Select
        Err.Clear
    End If
End Function

Posted by m_eguchi at February 4, 2006 04:21 PM
トラックバックURL

このエントリーのトラックバックURL:
http://www.kkkxcec.com/supportwlog/mt-tb.cgi/59