;;;Gu_xl 的源码-原理:除去所有文字对象句柄后,遍历做比对!
(defun C:duprem(/ a1 a2 a3 a4 delnum delss dlst edata elst ent ltest n num sle ss t0 t1 tes typa)
(setq delnum nil delnum 0)
(if (and (setq ss (ssget '((0 . "*TEXT")))) (= (type ss) 'PICKSET) (not (zerop (sslength ss))))
(progn
(setq n 0 num (sslength ss) elst nil dlst nil t0 (* 86400 (getvar "tdusrtimer")))
(while (< n num)
(setq ent (ssname ss n) edata (cdr (entget ent)) typa (cdr (assoc 0 edata)))
(setq a1 (assoc 5 edata));;句柄
(setq a2 (cons 5 ""));;句柄
(setq edata (subst a2 a1 edata))
(if (wcmatch (getvar "ACADVER") "*15*")
(progn
(setq a3 (assoc 330 edata));;句柄
(setq a4 (cons 330 ""));;句柄
(setq edata (subst a4 a3 edata))
)
)
(setq elst (cons ent elst) dlst (cons edata dlst) n (+ n 1))
)
(setq delss nil delss (ssadd) ltest dlst)
(setq n 0)
(setq tes (car ltest) ltest (cdr ltest) num nil num (length ltest))
(while (/= num 0)
(if (member tes ltest)
(progn
(setq delss (ssadd (nth n elst) delss))
(setq delnum (+ delnum 1))
)
)
(setq n (+ n 1))
(setq tes (car ltest) ltest (cdr ltest) num (length ltest))
)
(command "erase" delss "")
(redraw)
(setq t1 (* 86400 (getvar "tdusrtimer")))
(princ (strcat "共耗时:" (rtos (- t1 t0) 2 3) "秒,共删除文字:" (itoa delnum) "个!"))
)
)
(princ)
)