如何用autolisp写一个程序来删除指定图层上的所有对象?
我自己写的一个程序,好像不成功,可能思路都是错的.大家帮忙看看,应该如何来做.
(defun del-layer-ent(layername / ) (setq ss (ssget "x" layer=layername) len (sslength ss) i 0 ) (repeat len (setq name (ssname ss i)) (ssdel name ss) (setq i (1+ i) ) ) )
(defun del-layer-ent (layername / ss len i ename) (setq ss (ssget "x" (LIST (CONS 8 layername))) len (sslength ss) i 0 ) (repeat len (setq ename (ssname ss i)) (ENTdel ename) (setq i (1+ i) ) ) )
我老早以前编的一个小程序
(defun C:DELA(/ e n s) (princ "\n删除图层上所有实体.\n") (setq e (car (entsel "选择目标层上任一实体:"))) (if e (progn (setq e (entget e)) (setq n (cdr (assoc 8 e))) (setq s (ssget "X" (list (cons 8 n)))) (command "ERASE" s "") ) );end if (princ (strcat "已删除图层 " n " 上所有实体.")) (princ) );end DELA