Creates a selection set from the selected object
(ssget [sel-method] [pt1 [pt2]] [pt-list] [filter-list])
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).
- sel-method
-
A string that specifies the object selection method. Valid selection methods are
CP Cpolygon selection (all objects crossing and inside of the specified polygon).
I Implied selection (objects selected while PICKFIRST is in effect).
L Last visible object added to the database.
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 via 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).
: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.
:V Forces subentity selection. Treats all interactive, graphic selections performed by the user as subentity selections. The returned selection set contains subentities only. This option cannot be combined with the duplicate (":D") or nested (":N") selection modes. This option is supported only with interactive selections, such as window and crossing. It is not supported for all, filtered, or group selections.
- pt1
- pt2
- pt-list
- filter-list
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.
The name of the created selection set if successful; otherwise nil if no objects were selected.
Notes on the Object Selection Methods
- When using the :N selection method, 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, etc.) to the selection set. It is therefore possible to have multiple entries with the same entity name in the selection set (each will have different subentity information for ssnamex to report). Because the :N method does not guarantee that each entry will be unique, code that relies on uniqueness should not use selection sets created using this option.
- When using the L selection method in an MDI environment, you cannot always count on the last object drawn to remain visible. For example, if your application draws a line, and the user subsequently minimizes or cascades the AutoCAD drawing window, the line may no longer be visible. If this occurs, ssget with the "L" option will return nil.
Prompt the user to select the objects to be placed in a selection set:
Command: (ssget)
<Selection set: 2>
Create a selection set of the object passing through (2,2):
Command: (ssget '(2 2))
nil
Create a selection set of the most recently selected objects:
Command: (ssget "_P")
<Selection set: 4>
Create a selection set of the objects crossing the box from (0,0) to (1,1):
Command: (ssget "_C" '(0 0) '(1 1))
<Selection set: b>
Create a selection set of the objects inside the window from (0,0):
Command: (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 PICKFIRST is in effect):
Command: (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.
Command: (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:
Command: (ssget "_CP" pt_list)
<Selection set: 13>
Create a selection set of all blue lines inside the polygon defined by pt_list:
Command: (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.
-
Selection Set Handling and Selection Set Filter Lists in the AutoLISP Developer's Guide .