 ; Filthy - find and mark all occurrences of any entity type.
 ; Copyright 1995 by Rocket Software 
 ; Dedicated to Henry Kuttner for "The Misguided Halo."
 (DEFUN C:FILTHY ( / hi num bl blt ss rad len so txa pa)
  (setvar "cmdecho" 0)
  (setq hi (getvar "highlight"))
  (setq num 0)
  (setq blt (getstring "Entity type to mark or <Return> for everything: "))
  (if (= blt "")
      (setq ss (ssget "X"))
      (progn
           (setq bl (list (cons 0 blt)))
           (setq ss (ssget "X" bl))))
  (if ss
     (progn
          (setq rad (getdist (getvar "viewctr")
                                     "Marker length (<Return> for preset): "))
          (if (null rad)
                    (setq rad (/ (- (car (getvar "extmax"))
                                    (car (getvar "extmin"))) 25)))
          (setq len (strcat "/" (itoa (sslength ss))))
          (while (setq so (ssname ss 0))
                 (setq txa (entget so))
                 (setq num (1+ num))
                 (grtext -2 (strcat (itoa num) len))
                 (if (or (= (strcase blt t) "polyline")
                         (and (= blt "")
                              (= (cdr (assoc 0 txa)) "POLYLINE")))
                     (setq pa (cdr (assoc 10 (entget (entnext so)))))
                     (setq pa (cdr (assoc 10 txa))))
                 (grdraw (polar pa (/ pi 4) rad) (polar pa (* 1.25 pi) rad) 7)
                 (grdraw (polar pa (* pi 0.75) rad) (polar pa (* pi 1.75) rad) 7)
                 (ssdel so ss))
          (write-line (strcat "\nEntities found: " (itoa num)))
          (setq ss nil))
    (if (= bl "")
        (write-line "\nApparently this drawing is completely empty. ")
        (write-line "\nCan't find any such thing.")))
  (setvar "highlight" hi)
 (princ))