;; KILLDOTS.LSP ;; (c)1998-2002, John F. Uhden, Cadlantic/CADvantage ;; Recovered from the archives of the Compuserve ACAD Forum by ;; the ever jocular Tracy Lincoln, and returned to its author, ;; we present this "New and Improved" version (02-13-02). ;; This utility (for R12-R15) aims to delete all single-vertex ;; polylines, zero-length lines/polylines, and text with empty ;; strings or just spaces from a drawing. ;; ENJOY, or else! ;; NOTE: It bypasses, but does not stumble on locked layers. ;; (defun c:KILLDOTS ( / cmd ss i n fuzz e0 e ent dxflist data bad p x e>o) (defun dxflist (in dxf / memb out) (while (not (atom in)) (and (not (atom (setq memb (car in)))) (= (car memb) dxf) (setq out (cons (cdr memb) out)) ) (setq in (cdr in)) ) (reverse out) ) (if (= (type vl-load-com) 'SUBR) (vl-load-com) ) (setq i 0.0 n 0.0 x 0.0 fuzz 1e-11 e>o vlax-ename->vla-object) ;; Dummy command for undo control in all releases. (setq cmd (getvar "cmdecho")) (setvar "cmdecho" 0) (command "_.list" "") (setvar "cmdecho" cmd) (princ "\n") (if (setq ss (ssget "X" '((0 . "LINE,LWPOLYLINE,POLYLINE,TEXT")))) (while (< i (sslength ss)) (prompt (strcat "\rProcessing # " (rtos (1+ i) 2 0))) (setq e0 (ssname ss i) ent (entget e0) obj (cdr (assoc 0 ent)) i (1+ i) ) (cond ((= obj "LINE") (setq bad (equal (cdr (assoc 10 ent))(cdr (assoc 11 ent)) fuzz)) ) ((= obj "LWPOLYLINE") (setq bad (apply '= (mapcar '(lambda (x)(equal x (car data) fuzz))(setq data (dxflist ent 10)))) ) ) ((= obj "POLYLINE") (setq e (entnext e0) ent (entget e) p (cdr (assoc 10 ent)) bad 1 ) (while (and bad (= (cdr (assoc 0 ent)) "VERTEX")) (setq bad (equal (cdr (assoc 10 ent)) p fuzz) e (entnext e) ent (entget e) ) ) ) ((= obj "TEXT") (setq bad (wcmatch (cdr (assoc 1 ent)) ", ")) ; thanks to Steve Johnson ) ) (cond ((not bad)) ((and e>o (not (vl-catch-all-apply 'vla-delete (list (e>o e0))))) (setq n (1+ n)) ) ((entdel e0) (setq n (1+ n)) ) (1 (setq x (1+ x))) ) ) (prompt "No candidate objects found.") ) (and ss (princ (strcat "\nDeleted " (rtos n 2 0) " \"DOTS\"")) (> x 0) (princ (strcat "\nUnable to delete " (rtos x 2 0) " \"DOTS\"")) ) (princ) )