Function Definitions

 18  -  Selection Sets

ssget ..... Establishes a selection set and returns the name of the selection set

(ssget)  allows user to create a selection set interactively (similar to the SELECT command). Objects are highlighted as usual.

(ssget (list 1.75 4.0))  creates a selection set consisting of the entity that passes through the given point

(ssget "L")  creates a selection set consisting of the last entity added to the drawing database

(ssget "W" (list 1 1) (list 4 4)) creates a selection set consisting of all the entities fully inside the window designated by the given corners

(ssget "W" (setq p1 (getpoint "First point: ")) (getcorner p1 "Other point: "))  same as above, but allows user to locate points with pointer

(ssget "C" (list 1 1) (list 4 4))  creates a selection set consisting of all the entities inside or crossing the window designated by the given corners

(ssget "P")  creates a selection set consisting of the entities from the previous selection set (for example, from a selection set just created with the SELECT command)

Other arguments can bu used, based on the standard options for building selection sets, such as WP, CP, F.

(ssget "X" (list (cons 8 "0")))  creates a selection set of all drawing entities on layer "0". The first argument ("X") causes the ssget function to scan all entities and compile a selection set composed only of those that pass the requirements indicated in the second argument. The second argument is an association list using appropriate group codes.

After (setq dp1 (cons 0 "ARC")), which creates the dotted pair (0 . "ARC") and assigns it to dp1,
(ssget "X" (list dp1))  creates a selection set of all arcs
(ssget "X" (list (cons 0 "CIRCLE") (cons 8 "HIDDEN") (cons 40 1.5)))  creates a selection set of all circles that are on layer "Hidden" having a radius of 1.5. When two or more criteria are included in the second argument, all criteria must be met for the entity to be included in the selection set.

In the above example, the radius of a circle had to be exactly 1.5 to be included in the selection set.  By using a code -4 and a relational operator before indicating the radius, you could select all circles with a radius greater than 1.25 as follows:
(setq ss (ssget "X" (list (cons 0 "CIRCLE") (cons -4 ">") (cons 40 1.25))))

Logical operators such as AND and OR can also be used with code -4.  See AutoCAD R14 Customization Guide for more details.

(ssget "X") creates a selection set of all entities in the drawing including those on layers that are frozen or off.

Other group codes supported by the ssget "X" argument include:
 0 - entity type
 2 - block
 6 - linetype
 7 - text style
 8 - layer
 38 - elevation - must be real number, e.g..: (38 . 2.5)
 39 - thickness - must be real number, e.g..: (39 . 0.75)
 62 - color (0 = "BYBLOCK", 256 = "BYLAYER")
 66 - attributes follow flag, in insertion association lists
 210 - 3D extrusion direction vector (list of 3 reals)

The selection set consists of main entities only. Polyline vertices and block attributes are not included.

The selection set is typically assigned to a variable, as follows:  (setq ss1 (ssget))   This selection set can be fed to AutoCAD whenever it is prompting for general object selection. For example, after entering ERASE and being prompted to select objects, you could enter !ss1 (assuming you have assigned a selection set to variable ss1). This selection set can also be used inside a command function:  (command ".erase" ss1 "").

Selection sets do not carry over to subsequent editing sessions.


ssadd ..... Adds an element to an existing or new selection set

(ssadd en s1)  adds the entity name in variable en to selection set s1 and returns the new enlarged selection set. The selection set assigned to s1 is automatically changed.

(ssadd en)  creates a new selection set containing the entity name in variable en, and returns that set

(ssadd)  creates a new empty selection set and returns that set


ssdel ..... Removes an element from a selection

(ssdel en s1)  deletes the entity name in variable en from selection set s1 and returns the new smaller selection set. The selection set assigned to s1 is automatically changed.  The entity is not deleted from the drawing database. 


sslength ..... Returns the number of entities in a given selection set, as an integer

(sslength s1)  returns the number of entities in the selection set assigned to variable s1


ssmemb ..... Tests for the presence of an entity in a selection

(ssmemb en s1)  returns the entity name (en) if that entity is a member of selection set s1, Otherwise it returns nil.


ssname ..... Returns the entity name of a given element in a given selection set.  Elements are numbered beginning with 0.  Retrieves main entity names only. To retrieve sub-entity names use entnext.

(ssname s1 0)  returns the 1st entity name in selection set s1
(ssname s3 5)  returns the 6th entity name in selection set s3. If s3 contained only 5 entities, this expression would return nil.


ssnamex ..... Retrieves information about how an item in a selection set was selected.  Specifies which of the following was used: Last, All, Pick, Window, WPolygon, Crossing, CPolygon, or Fence.

ssgetfirst ..... Finds which entities are gripped and selected

While using grips, with some entities gripped and others both selected and gripped,
(ssgetfirst)  returns a list containing two selection sets.  The first selection set includes entities that are gripped only.  The second selection set includes entities that are both gripped and selected.


sssetfirst ..... Sets which entities are gripped and selected

If s1 and s2 are selection sets,
(sssetfirst s1 s2)  puts grips on the entities in s1 and both puts grips on and selects the entities in s2.  The first argument can be nil.  The second argument is optional.  If any entities are common to both selection sets, the first selection set is ignored and the second selection set is both gripped and selected.


HOME


Copyright © 1988, 1998 Ronald W. Leigh