 ; Wblock all blocks within a drawing - that is, write them to the disk as
 ; independent drawing files.  Optionally overwrite existing drawings.
 ; Copyright 1992  Rocket Software Ltd.
 ; Find all the ME-262 blueprints hidden in your flow charts.
 (DEFUN C:BLOCKOUT (/ num enum anon exist notex over rewind total)
  (setvar "cmdecho" 0)
  (setq num 0)
  (setq enum 0)
  (setq anon 0)
  (setq exist "")
  (setq notex "")
  (setq over (getstring "Overwrite existing blocks? <Y>: "))
  (setq over (strcase over))
  (if (or (= over "Y") (= over "YES") (= over ""))
      (setq over T)
      (setq over ()))
  (setq rewind T)
  (while (setq blnam (cdr (assoc 2 (tblnext "block" rewind))))
         (if rewind (setq rewind ()))
         (grtext -2 blnam)
         (if (= (substr blnam 1 1) "*")
             (setq anon (1+ anon))
             (if (findfile (strcat blnam ".dwg"))
                 (progn
                      (setq exist (strcat exist " " blnam))
                      (if over
                         (progn
                              (command "wblock" blnam "Y" blnam)   ; temp fix
                              (setq enum (1+ enum)))))
                 (progn
                      (setq notex (strcat notex " " blnam))
                      (command "wblock" blnam blnam)
                      (setq num (1+ num))))))
  (if (or (/= exist "") (/= notex "") (> anon 0))
      (progn
           (if (/= notex "")
               (write-line (strcat (itoa num) " blocks wblocked:" notex)))
           (if (/= exist "")
               (write-line (strcat "\n" (if (> enum 0)
                                            (strcat (itoa enum) " e") "E")
                                   "xisting blocks"
                                   (if over "" " not") " overwritten:" exist)))
           (if (> anon 0)
               (write-line (strcat "\n" (itoa anon)
                                   " anonymous block" (if (> anon 1) "s" "")
                                   " ignored"))))
      (write-line "No blocks found"))
 (PRINC))