GetObject メソッド(ActiveX)

オブジェクトの名前(キーワード)を指定して、ディクショナリ内のオブジェクトを取得します。

サポートされているプラットフォーム: Windows のみ

構文と要素

VBA:

RetVal = object.GetObject(Name)
object

タイプ: Dictionary

このメソッドが適用されるオブジェクト。

Name

アクセス: 入力のみ

タイプ: 文字列

ディクショナリ内のオブジェクトの名前(キーワード)。

戻り値(RetVal)

タイプ: Object

指定された名前(キーワード)に対応するオブジェクト

注意

たとえば、次のディクショナリで「SecondKeyword」という名前で問い合わせると、「Object2」というオブジェクトが返されます。

MyDictionary

Keyword - Object

FirstKeyword - Object1

SecondKeyword - Object2

VBA:

Sub Example_GetObject()
    ' This example creates a dictionary and adds
    ' a custom object to that dictionary. It then
    ' returns the object using GetObject.
    
    Dim dictObj As AcadDictionary
    Set dictObj = ThisDrawing.Dictionaries.Add("TEST_DICTIONARY")
    
    ' Load the ARX application that defines the custom object.
    ' Note: The application listed here does not exist and
    ' will cause an error when run. Change the application name
    ' to the path and name of your ARX Application.
    On Error GoTo ERRORHANDLER
    ThisDrawing.Application.LoadArx "MyARXApp.dll"
    
    ' Create the custom object in the dictionary
    Dim keyName As String
    Dim className As String
    Dim customObj As AcadObject
    
    keyName = "OBJ1"
    className = "CAsdkDictObject"
    
    Set customObj = dictObj.AddObject(keyName, className)
    
    ' Find the object
    Dim tempObj As Object
    Set tempObj = dictObj.GetObject(keyName)
    
ERRORHANDLER:
    MsgBox Err.Description, , "GetObject Example"
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_GetObject()
    ;; This example creates a dictionary and adds
    ;; a custom object to that dictionary.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    (setq dictionaries (vla-get-Dictionaries doc))
  
    (setq dictObj (vla-Add dictionaries "TEST_DICTIONARY"))
    
    ;; Load the ObjectARX application that defines the custom object.
    ;; Note: The application listed here does not exist and
    ;; will cause an error when run. Change the application name
    ;; to the path and name of your ObjectARX application.
    (vla-LoadArx acadObj "MyARXApp.dll")
    
    ;; Create the custom object in the dictionary
    (setq keyName "OBJ1")
    (setq className "CAsdkDictObject")

    (setq customObj (vla-AddObject dictObj keyName className))

    ;; Find the object
    (setq tempObj (vla-GetObject dictObj keyName))
)