获取集合、组或选择集中给定索引处的成员对象。 支持的平台:仅窗口 签名工 务 局: RetVal = object.Item(Index) 返回值(RetVal)类型:对象 集合或选择集中给定索引位置的对象。 言论此方法支持基于字符串的迭代。例如,如果使用以下语句创建了名为 BLOCK1 的块: Set block1 = Blocks.Add("BLOCK1")
您可以通过以下语句引用对象: Set whichblock = Blocks.Item("BLOCK1")
注意:Item 方法在与集合一起使用时区分大小写;对于其他集合,它不区分大小写。SelectionSets
字典:此方法的返回值类型为。这允许您从字典集合中检索不属于该类型的命名对象。IAcadObjectDictionary 例子工 务 局: 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"))
)
|
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-10-29 08:50
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.