Gets the number of items in the object.
Supported platforms: Windows only
VBA:
object.Count
Type: All Collections, Block, Dictionary, Group, Materials, SectionManager, SelectionSet
The object this property applies to.
Read-only: Yes
Type: Integer
The number of items in the object.
No additional remarks.
VBA:
Sub Example_Count() ' Use count to retrieve the number of objects in a collection ' You might use this value in a loop structure to iterate through the collection MsgBox "There are " & ThisDrawing.Layers.Count & " layer(s) in the drawing." MsgBox "There are " & ThisDrawing.ModelSpace.Count & " object(s) in ModelSpace." Dim objCount As Integer Dim I As Integer objCount = ThisDrawing.ModelSpace.Count Dim mspaceObj As AcadObject For I = 0 To objCount - 1 Set mspaceObj = ThisDrawing.modelSpace.Item(I) MsgBox "The objects in ModelSpace include: " & mspaceObj.ObjectName, vbInformation, "Count Example" Next End Sub
Visual LISP:
(vl-load-com) (defun c:Example_Count() ;; Use count to retrieve the number of objects in a collection ;; You might use this value in a loop structure to iterate through the collection (setq acadObj (vlax-get-acad-object)) (setq doc (vla-get-ActiveDocument acadObj)) (alert (strcat "There are " (itoa (vla-get-Count (vla-get-Layers doc))) " layer(s) in the drawing.")) (alert (strcat "There are " (itoa (vla-get-Count (vla-get-ModelSpace doc))) " object(s) in ModelSpace.")) (setq I 0 objCount (vla-get-Count (vla-get-ModelSpace doc))) (while (>= (- objCount 1) I) (setq mspaceObj (vla-Item (vla-get-ModelSpace doc) I) I (1+ I)) (alert (strcat "The objects in ModelSpace include: " (vla-get-ObjectName mspaceObj))) ) )