AutoCAD allows users to select entities in either a verb-noun or a noun-verb manner. A verb-noun selection is one in which a command is issued first, followed by a selection of entities to work with. A noun-verb selection is one in which entities are selected first and then a command that uses them is issued. One of the benefits of noun-verb selection is that by performing only one selection, you can run multiple independent commands in sequence on the same set of entities without having to explicitly use the Previous option.
The selection of entities built by the user when AutoCAD is idle at the command prompt is called the PickFirst selection set. This selection set is available via the read-only PickfirstSelectionSet property of each drawing object. A special SelectionSet named PICKFIRST is created by AutoCAD whenever the property is accessed. If the user does not preselect any entities, this selection set will be empty.
Set SelectionSetObject = DocumentObject.PickfirstSelectionSet
By using the SelectionChanged event of each Document object, you can receive notification every time the user adds entities to or removes entities from the PickFirst selection set. This event is fired any time the PickFirst selection set is altered. Chapter 4 discusses events in more detail.
To demonstrate that the SelectionChanged event is triggered, the following example, which you should place in the ThisDrawing module, tells the user how many objects are in the PickFirst selection set and then changes the highlight of the PickFirst selection set after a half second.
Private Sub AcadDocument_SelectionChanged() Dim objSS As AcadSelectionSet Dim dblStart As Double
'' get the pickfirst selection from drawing Set objSS = ThisDrawing.PickfirstSelectionSet
'' highlight the selected entities objSS.Highlight True
MsgBox "There are " & objSS.Count & " objects in selection set:
'' delay for 1/2 second dblStart = Timer
Do While Timer < dblStart + 0.5
'' unhighlight the selected entities objSS.Highlight False End Sub
Was this article helpful?