- ;;框内物体删除 By Gu_xl
- (defun c:tt (/ OS P1 P2 CP SS ENREC N *error*)
- (defun *error* (s)
- (setvar "osmode" os)
- (princ s)
- )
- (setq os (getvar "osmode"))
- (setvar "osmode" 0)
- (setq p1 (getpoint "\n指定基点:"))
- (setq p2 (getcorner p1 "\n指定对角点:"))
- (setq cp (mapcar '* '(0.5 0.5 0.5) (mapcar '+ p1 p2)))
- (setq ss (ssget "w" p1 p2))
- (if ss (command "erase" ss ""))
- (command "rectang" p1 p2)
- (setq enRec (entlast))
- ;;重复5次,以保证剪切干净
- (repeat 5
- (setq ss (ssget "c" p1 p2))
- (ssdel enRec ss)
- (command ".trim" enRec "")
- (repeat (setq n (sslength ss))
- (command (list (ssname ss (setq n (1- n))) cp))
- )
- (command "")
- )
- ;;删除绘制的方框
- (entdel enRec)
- (setvar "osmode" os)
- (princ)
- )
|