;只选择蓝色矩形
(ssget '((0 . "LWPOLYLINE") (62 . 5)))
;删除蓝色矩形
(command "erase" (ssget '((0 . "LWPOLYLINE") (62 . 5))) "")
;返回第一个矩形左上角二维坐标
(cdr(nth 15 (entget(ssname (ssget '((0 . "LWPOLYLINE") )) 0))))
;返回第一个矩形右下角二维坐标
(cdr(nth 23 (entget(ssname (ssget '((0 . "LWPOLYLINE") )) 0))))

;批量打印图纸
;把DWG To PDF.pc3"改成实际打印机名
;1、用蓝色矩形框出要打印的图纸
;2、调用函数全选所有矩形
(defun f()
    (setq s (ssget '((0 . "LWPOLYLINE")(62 . 5) )))
    (setq sl (sslength s))
    (setq i 0)
    (while (< i sl)
        (setq e (entget(ssname s i)))
        (setq p1 (cdr(nth 15 e)))
        (setq p2 (cdr(nth 23 e)))
        (setq nm (itoa i))
        (setq i(1+ i))
        (command "plot" "Y" "" "DWG To PDF.pc3" "" "M" "L" "N" "W" p1 p2 "f" "c" "y" "monochrome.ctb" "n" "w" nm "n" "y")
    )
)