Item Example

Using Programming Languages other than 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)

	' 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