AutoLISP provides a number of functions for handling selection sets. For a complete list of selection set functions, see Selection Set Manipulation Functions in AutoLISP Function Synopsis
The ssget function provides the most general means of creating a selection set. It can create a selection set in one of the following ways:
- Explicitly specifying the objects to select, using the Last, Previous, Window, Implied, WPolygon, Crossing, CPolygon, or Fence options
- Specifying a single point
- Selecting the entire database
- Prompting the user to select objects
With any option, you can use filtering to specify a list of attributes and conditions that the selected objects must match.
The first argument to ssget is a string that describes which selection option to use. The next two arguments, pt1 and pt2, specify point values for the relevant options (they should be left out if they don't apply). A point list, pt-list, must be provided as an argument to the selection methods that allow selection by polygons (that is, Fence, Crossing Polygon, and Window Polygon). The last argument, filter-list, is optional. If filter-list is supplied, it specifies the list of entity field values used in filtering. For example, you can obtain a selection set that includes all objects of a given type, on a given layer, or of a given color. Selection filters are described in more detail in Selection Set Filter Lists.
See the ssget entry in the AutoLISP Reference for a list of the available selection methods and the arguments used with each.
The following table shows examples of calls to ssget:
When an application has finished using a selection set, it is important to release it from memory. You can do this by setting it to nil:
(setq ss1 nil)
Attempting
to manage a large number of selection sets simultaneously is not recommended.
An AutoLISP application cannot have more than 128 selection sets
open at once. (The limit may be lower on your system.) When the limit
is reached, AutoCAD will not create more selection sets. Keep
a minimum number of sets open at a time, and set unneeded selection
sets to nil as soon as
possible. If the maximum number of selection sets is reached, you must
call the