An entity filter list is an association list that uses DXF group codes in the same format as a list returned by entget. (See the DXF Reference for a list of group codes.) The ssget function recognizes all group codes except entity names (group -1), handles (group 5), and xdata codes (groups greater than 1000). If an invalid group code is used in a filter-list, it is ignored by ssget. To search for objects with xdata, use the -3 code as described in Filtering for Extended Data.
When a filter-list is provided as the last argument to ssget, the function scans the selected objects and creates a selection set containing the names of all main entities matching the specified criteria. 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.
The filter-list specifies which property (or properties) of the entities are to be checked and which values constitute a match.
The following examples demonstrate methods of using a filter-list with various object selection options.
If both the code and the desired value are known, the list may be quoted as shown previously. If either is specified by a variable, the list must be constructed using the list and cons function. For example, the following code creates a selection set of all objects in the database that are on layer FLOOR3:
(setq lay_name "FLOOR3")
(setq ss1
(ssget "X"
(list (cons 8 lay_name))
)
)
If the filter-list specifies more than one property, an entity is included in the selection set only if it matches all specified conditions, as in the following example:
(ssget "X" (list (cons 0 "CIRCLE")(cons 8 lay_name)(cons 62 1)))
This code selects only Circle objects on layer FLOOR3 that are colored red. This type of test performs a Boolean “AND” operation. Additional tests for object properties are described in Logical Grouping of Filter Tests.
The ssget function filters a drawing by scanning the selected entities and comparing the fields of each main entity against the specified filtering list. If an entity's properties match all specified fields in the filtering list, it is included in the returned selection set. Otherwise, the entity is not included in the selection set. The ssget function returns nil if no entities from those selected match the specified filtering criteria.
When ssget filters a drawing, the selection set it retrieves might include entities from both paper space and model space. However, when the selection set is passed to an AutoCAD command, only entities from the space that is currently in effect are used. (The space to which an entity belongs is specified by the value of its 67 group. Refer to the Customization Guide for further information.)