ssget (AutoLISP)

Creates a selection set from the selected object

Supported Platforms: Windows and Mac OS

Signature

(ssget [sel-method] [pt1 [pt2]] [pt-list] [filter-list])
sel-method

Type: String

Object selection method.

Valid selection methods are

C -- Crossing selection.

CP -- Cpolygon selection (all objects crossing and inside of the specified polygon).

F -- Fence selection.

I -- Implied selection (objects selected while the AutoCAD PICKFIRST system variable is in effect).

L -- Last visible object added to the database.

P -- Last selection set created.

W -- Window selection.

WP -- WPolygon (all objects within the specified polygon).

X -- Entire database. If you specify the X selection method and do not provide a filter-list, ssget selects all entities in the database, including entities on layers that are off, frozen, and out of the visible screen.

:E -- Everything within the cursor's object selection pickbox.

:N -- Call ssnamex for additional information on container blocks and transformation matrices for any entities selected during the ssget operation. This additional information is available only for entities selected through graphical selection methods such as Window, Crossing, and point picks.

Unlike the other object selection methods, :N may return multiple entities with the same entity name in the selection set. For example, if the user selects a subentity of a complex entity such as a BlockReference, PolygonMesh, or old style polyline, ssget looks at the subentity that is selected when determining if it has already been selected. However, ssget actually adds the main entity (BlockReference, PolygonMesh, and so on) to the selection set. The result could be multiple entries with the same entity name in the selection set (each will have different subentity information for ssnamex to report).

:R -- Allows entities in a long transaction to be selected.

:S -- Allow single selection only.

:U -- Enables subentity selection. Cannot be combined with the duplicate (":D") or nested (":N") selection modes. In this mode, top-level entities are selected by default, but the user can attempt to select subentities by pressing the CTRL key while making the selection. This option is supported only with interactive selections, such as window, crossing, and polygon. It is not supported for all, filtered, or group selections.

pt1

Type: List

A point relative to the selection.

pt2

Type: List

A point relative to the selection.

pt-list

Type: List

A list of points.

filter-list

Type: List

An association list that specifies object properties. Objects that match the filter-list are added to the selection set.

Return Values

Type: Pickset (selection set) or nil

The name of the created selection set if successful; otherwise nil if no objects were selected.

Remarks

Selection sets can contain objects from both paper and model space, but when the selection set is used in an operation, ssget filters out objects from the space not currently in effect. Selection sets returned by ssget contain main entities only (no attributes or polyline vertices).

If you omit all arguments, ssget prompts the user with the Select Objects prompt, allowing interactive construction of a selection set.

If you supply a point but do not specify an object selection method, AutoCAD assumes the user is selecting an object by picking a single point.

Examples

Prompt the user to select the objects to be placed in a selection set:

(ssget)
<Selection set: 2>

Create a selection set of the object passing through (2,2):

(ssget '(2 2))
nil

Create a selection set of the most recently selected objects:

(ssget "_P")
<Selection set: 4>

Create a selection set of the objects crossing the box from (0,0) to (1,1):

(ssget "_C" '(0 0) '(1 1))
<Selection set: b>

Create a selection set of the objects inside the window from (0,0):

(ssget "_W" '(0 0) '(5 5))
<Selection set: d>

By specifying filters, you can obtain a selection set that includes all objects of a given type, on a given layer, or of a given color. The following example returns a selection set that consists only of blue lines that are part of the implied selection set (those objects selected while the AutoCAD PICKFIRST system variable is in effect):

(ssget "_I" '((0 . "LINE") (62 . 5)))
<Selection set: 4>

The following examples of ssget require that a list of points be passed to the function. The pt_list variable cannot contain points that define zero-length segments.

Create a list of points:

(setq pt_list '((1 1)(3 1)(5 2)(2 4)))
((1 1) (3 1) (5 2) (2 4))

Create a selection set of all objects crossing and inside the polygon defined by pt_list:

(ssget "_CP" pt_list)
<Selection set: 13>

Create a selection set of all blue lines inside the polygon defined by pt_list:

(ssget "_WP" pt_list '((0 . "LINE") (62 . 5)))
<Selection set: 8>

The selected objects are highlighted only when ssget is used with no arguments. Selection sets consume AutoCAD temporary file slots, so AutoLISP is not permitted to have more than 128 open at one time. If this limit is reached, AutoCAD cannot create any more selection sets and returns nil to all ssget calls. To close an unnecessary selection set variable, set it to nil.

A selection set variable can be passed to AutoCAD in response to any Select objects prompt at which selection by Last is valid. AutoCAD then selects all the objects in the selection set variable.

The current setting of Object Snap mode is ignored by ssget unless you specifically request it while you are in the function.