Collection Functions

Here are various functions for manipulating VLA Collections. Information about the purpose, arguments and returns of each function is detailed in the code header for each function.

Get Item

Select all
;; VLA-Collection: Get Item  -  Lee Mac
;; Retrieves the item with index 'idx' if present in the supplied collection
;; col - [vla]     VLA Collection Object
;; idx - [str/int] Index of the item to be retrieved

(defun LM:getitem ( col idx / obj )
    (if (not (vl-catch-all-error-p (setq obj (vl-catch-all-apply 'vla-item (list col idx)))))
        obj
    )
)

Example Function Call

This example retrieves the VLA Layer Object for layer "0" from the Layers Collection.

(LM:getitem (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) "0")

Get All Items

Select all
;; VLA-Collection: Get All Items  -  Lee Mac
;; Returns a list of all items in the supplied collection
;; col - [vla] VLA Collection Object

(defun LM:getallitems ( col / rtn )
    (vlax-for obj col (setq rtn (cons obj rtn)))
    (reverse rtn)
)

Example Function Call

This example returns a list of all VLA Layer Objects residing in the Layers Collection.

(LM:getallitems (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))))

textsize

increase · reset · decrease

Designed & Created by Lee Mac © 2010