 ; Find and mark all blocks or all occurrences of a specified block.
 ; By SW for Rocket Software  Copyright 1991
 ; Endlessly valuable for those times when you can't think...of...you know.
 (DEFUN C:FIBL (/ hi num bl enampt entt nogo ss rad len so txa pa)
  (setvar "cmdecho" 0)
  (setq hi (getvar "highlight"))
  (setq num 0)
  (setq bl (getstring "Block to find or <Return> to select: "))
  (if (= bl "")
      (progn
           (setq enampt (entsel "Select a block or <Return> for all: "))
           (if enampt
               (progn
                    (setq entt (entget (car enampt)))
                    (setq bl (cdr (assoc 2 entt)))
                    (if bl
                        (prompt bl)
                        (progn
                             (write-line "\nThat was not a block.")
                             (setq nogo T))))
               (setq bl ()))))
  (if bl
      (progn
           (if (= (substr bl 1 1) "*")       ; escape leading * so that can
               (setq bl (strcat "`" bl)))    ; find hatching blocks
           (setq bl (list (cons 2 bl)))
           (setq ss (ssget "X" bl)))
      (if (null nogo) (setq ss (ssget "X" '((0 . "INSERT"))))))
  (if ss
     (progn
          (setq rad (getdist (getvar "viewctr")
                                    "\nMarker 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))
                 (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 "\nBlocks found: " (itoa num)))
          (setq ss nil))
    (if (null nogo)
        (if bl
           (write-line "\nCan't find any such block. ")
           (write-line "\nApparently there are no blocks in this drawing. "))))
  (setvar "highlight" hi)
 (PRINC))