Manipulating Selection Sets with autolisp in AutoCAD

Once a selection set is created, a variety of functions can be used to make changes to the selection set or to give you information about it.

Explanation: the (ssxxx) functions


In this practice you will modify the previous Move and Rotate routine to make sure that you have selected or deselected all the desired objects. Estimated time for completion: 10 minutes.

Steps to the solution

1. Use (ssadd) to add any additional items to the selection set.

2. Use (ssdel) to remove any unwanted items from the selection set.


(defun C:MoveRotate ()
(setq CE-SAVE (getvar “cmdecho”))
(setvar “cmdecho” 0)
(setq SS (ssget))
(while (setq ENAME (car (entsel “\nAdd any additional items to selection set: “)))
         (ssadd ENAME SS)
(while (setq ENAME (car (entsel “\nRemove any unwanted items from the selection set: “)))
          (ssdel ENAME SS)
            (setq CP (getpoint “\nBase point: “))
(setq PT2 (getpoint “\nSecond point: “))
(setq ANG (getdist “\nRotation Angle: “))
(command “move” SS “” CP PT2)
(command “rotate” SS “” PT2 ANG)
(setvar “cmdecho” CE-SAVE)

  • A complete solution to this exercise is on your class disk as MOVEROTATE-B.LSP
See also  The Simplest Looping Function (repeat) with autolisp in AutoCAD
Back to top button