Retrieving Member Objects in a Collection

AutoCAD AutoLISP & Visual LISP

 
Retrieving Member Objects in a Collection
 
 
 

The Item method retrieves a member object from a collection. The Count property shows the number of items in a collection. Using the Item method and Count property, you can individually process each object in a collection. For example, you can look at each object in a model space, determine the type of object, and process only the types of objects you are interested in. The following code prints the start angle for each arc object in a model space:

(setq index 0)
(repeat   (vla-get-count mspace)
  (if (= "AcDbArc" (vla-get-objectname (vla-item mspace index)))
    (progn
      (princ "\nThe start angle of the arc is ")
      (princ (vla-get-startangle (vla-item mspace index)))
    )
  )
  (setq index (+ index 1))
)

Note that Item and Count also apply to groups and selection sets.