Share
 
 

About Accessing a Collection (ActiveX)

Most collection objects are accessed through the Document object. The Document object contains a property for each of the Collection objects.

For example, the following code defines a variable and sets it to the Layers collection of the current drawing:

AutoLISP
(setq acadObj (vlax-get-acad-object)
      doc (vla-get-ActiveDocument acadObj)
      layerCollection (vla-get-Layers doc))
VBA (AutoCAD Only)
Dim layerCollection as AcadLayers
Set layerCollection = ThisDrawing.Layers

The Documents collection, MenuBar collection, and MenuGroups collection are accessed through the Application object. The Application object contains a property for each of these collections. For example, the following code defines a variable and sets it to the MenuGroups collection for the application:

AutoLISP
(setq MenuGroupsCollection (vla-get-MenuGroups (vlax-get-acad-object)))
VBA (AutoCAD Only)
Dim MenuGroupsCollection as AcadMenuGroups
Set MenuGroupsCollection = ThisDrawing.Application.MenuGroups

Was this information helpful?