Besides using the standard selection set tools analogous to AutoCAD (Window, Crossing, Previous, Last, etc.), AutoLISP provides a mechanism, through the (ssget) filter, to select all entities within a drawing that have specific properties.

Explanation: the (ssget “X”) function

(ssget “X” filter-list)

The “X” mode of the (ssget) function scans the entire drawing and creates a selection set containing the names of all main entities that match the criteria specified in the filter-list.

The filter-list is an association list that contains a series of entity property association pairs, the DXF code and the corresponding answer (8 . “layer name”), that are desired to be selected. See next page for list of available DXF codes.


(setq SS1 (ssget “x” ‘((8 . “object”))))
The code above would select all entities in the drawing located on the OBJECT layer.
(setq SS2 (ssget “x” ‘((8 . “object”) (0 . “line”))))
The code above would select all lines with linetype DASHED in the drawing located on the OBJECT layer.

  • An empty or absent filter-list would cause (ssget “x”) to select all entities in the drawing.

DXF Codes

Here are some of the more commonly used DXF codes accepted by the (ssget “X”) function:


In this practice you will create a routine that will select all the text objects in a file and change their layer to the layer TEXT. This uses the (ssget “X”) function. Note the similarity to the (changeblock) routine that we created earlier. Estimated time for completion: 10 minutes.


;;;TEXTLAYER – moves all text in a drawing to the
;;; “Text” layer
(defun C:TEXTLAYER ()
(setq CE-SAV (getvar “cmdecho”))
(setvar “cmdecho” 0)
(setq SS (ssget “x” ‘((0 . “text”)) ))
(setq POSITION 0)
(while (setq ENAME (ssname SS POSITION))
(setq OLDELIST (entget ENAME)
NEWLAYERNAMELIST (cons 8 “text”)
) ;_ end of setq
(entmod NEWELIST)
) ;_ end of while
(setq SS nil)
(setvar “cmdecho” CE-SAV)
) ;_ end of defun

  • A complete solution to this exercise is on your class disk as TEXTLAYER-A.LSP
Processing Entities within a Selection Set - AutoCAD Autolisp tutorial 33
Additional Filter Options for (ssget) - AutoCAD Autolisp tutorial 35