;TIP557.LSP   Show Block Occurrences   (c)1990, Brian Sallade
(defun C:SHBLKS (/ A B C CNTR)
  (setq SEARCH nil)
  (while (= SEARCH nil)
    (setq A (strcase (getstring
        "\nBlock to show or <ALL>: "))
    )
    (If (= A "") (setq A "ALL"))
    (If (= A "ALL")
      (setq SEARCH T)
      (setq SEARCH
        (tblsearch "block" A))
    )
    (If (= SEARCH nil)
      (prompt (strcat
        "No block named " A " found."))
    )
  )
  (setq B (entnext) CNTR 0)
  (While (boundp 'B)
    (setq C (entget B))
    (if (= (cdr (assoc 0 C)) "INSERT")
      (progn
        (If (= A "ALL") (progn
          (setq CNTR (1+ CNTR))
          (redraw (cdr (assoc -1 C)) 3)
        ))
        (If (= (cdr (assoc 2 C)) A)
          (progn
            (setq CNTR (1+ CNTR))
            (redraw (cdr(assoc -1 C)) 3)
          )
        )
      )
    )
    (setq B (entnext B))
  )
  (prompt (strcat "Showed "
    (itoa CNTR) " occurances of " A))
(princ)
)

