コレクション、グループ、または選択セット内の指定されたインデックスに従って、メンバー オブジェクトを取得します。
サポートされているプラットフォーム: Windows のみ
VBA:
RetVal = object.Item(Index)
タイプ: すべてのコレクション、Group、SelectionSet
このメソッドが適用されるオブジェクト。
アクセス: 入力のみ
タイプ: バリアント型
取得したいメンバー オブジェクトの、コレクション内でのインデックス位置を指定します。
インデックスは整数または文字列でなければなりません。インデックスを整数で指定する場合、0~N-1 の範囲でなければなりません(N は、コレクションまたは選択セット内のオブジェクト数)。
タイプ: Object
コレクションまたは選択セット内の指定されたインデックス位置にあるオブジェクト
このメソッドは、文字列ベースの繰り返し処理をサポートします。たとえば、次の文によって作成された BLOCK1 というブロックがあるとします。
Set block1 = Blocks.Add("BLOCK1")
このオブジェクトを参照するには次の文を使用します。
Set whichblock = Blocks.Item("BLOCK1")
Dictionaries: このメソッドの戻り値のタイプは IAcadObject です。名前の付いたオブジェクトを AcadDictionary タイプではないディクショナリのコレクションから取り出すことができます。
VBA:
Sub Example_Item()
    ' This example shows two uses of the Item method.
    ' The first uses Item with an index counter to return an item in a collection.
    ' The second uses Item with a string to return an item in a collection.
    
    ' Iterate thru the model space collection,
    ' get all the items in the collection
    ' and store them in an array called newObjs
    Dim count As Integer
    count = ThisDrawing.ModelSpace.count
    
    ReDim newObjs(count) As AcadEntity
    Dim index As Integer
    For index = 0 To count - 1
        Set newObjs(index) = ThisDrawing.ModelSpace.Item(index)
    Next
    
    ' Get a particular item, in this case a layer, based on name "0"
    Dim layerObj As AcadLayer
    Set layerObj = ThisDrawing.Layers.Item("0")
    
End Sub
Visual LISP:
(vl-load-com)
(defun c:Example_Item()
    ;; This example shows two uses of the Item method.
    ;; The first uses Item with an index counter to return an item in a collection.
    ;; The second uses Item with a string to return an item in a collection.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
    ;; Iterate thru the model space collection,
    ;; get all the items in the collection
    ;; and store them in an array called newObjs
    (setq count (vla-get-Count (vla-get-ModelSpace doc))
          index 0)
    
    (setq newObjs (vlax-make-safearray vlax-vbObject (cons 0 count)))
    (while (>= (1- count) index)
        (vlax-safearray-put-element newObjs index (vla-Item (vla-get-ModelSpace doc) index))
        (setq index (1+ index))
    )
    
    ;; Get a particular item, in this case a layer, based on name "0"
    (setq layerObj (vla-Item (vla-get-Layers doc) "0"))
)