Friday, August 9, 2013

AutoLISP Program For Drawing A Cabinet 2

Empty Screen


When we draw the cabinet, we want to start with an empty screen. Everything that is on the screen has to be deleted first.


The CLSCR Function


We do that with the CLSCR function. Here it is:


(defun clscr (/ ss)
   (command "zoom" "extents")
   (setq p1 (getvar "vsmin")
            p2 (getvar "vsmax")
   )
   (setq ss (ssget "c" p1 p2))
   (if ss
      (command "erase" "all" "")
   )
)


How The Function Works


This is how the function works. We start with the ZOOM command. We choose the extents option of that command.


The corner points of the screen are stored in the system variables VSMIN and VSMAX. The values go to the P1 and P2 variable.


Next the SSGET function is used. The area between the points P1 and P2 is selected. There is checked whether entities can be found there.


If entities are found there, then the variable SS gets a value. If no entities are found, then the variable SS has got the value nil.


If the variable SS has got a value, then the ERASE command is invoked. All entities are deleted. And we have an empty screen.


The Next Post



In the next post I'm going to talk about entering the sizes of the cabinet. That is done with a dialog box. Wait till the next post.

No comments:

Post a Comment