home *** CD-ROM | disk | FTP | other *** search
/ Current Shareware 1994 January / SHAR194.ISO / cad_util / dt100.zip / EDTITLE.LSP < prev    next >
Lisp/Scheme  |  1993-09-25  |  5KB  |  236 lines

  1. ; DrafTools   [Version 1.00] 9/25/93       
  2. ;
  3. ; ***************************************
  4. ; ****  Author:  Owen Wengerd        ****
  5. ; ****                               ****
  6. ; ****  Manu-Soft Computer Services  ****
  7. ; ****  P.O. Box 84                  ****
  8. ; ****  Fredericksburg, OH  44627    ****
  9. ; ****  (216) 695-5903               ****
  10. ; ****  Compu-Serve ID:  71324,3252  ****
  11. ; ***************************************
  12.  
  13.  
  14. (defun C:EDTITLE ( / 
  15.  
  16.  
  17. ;*** Local Variables ***
  18.  
  19.   as 
  20.   il 
  21.   p 
  22.   ca 
  23.   t1 
  24.   oldvar 
  25.   olderr 
  26.   restore
  27.  
  28.  
  29. ;*** Local Functions ***
  30.  
  31.   edtitlex
  32.   errexit
  33.   fpath
  34.   get_attrib
  35.   )
  36.  
  37.  
  38. ; *****************  Function Definitions  *****************
  39.  
  40. (defun edtitlex ()
  41.   (setvar "OSMODE" (nth 1 oldvar))
  42.   (setvar "REGENMODE" (nth 2 oldvar))
  43.   (setvar "EXPERT" (nth 3 oldvar))
  44.   (setvar "CMDECHO" (car oldvar))
  45.   (setq *error* olderr)
  46.   (princ)
  47. )
  48.  
  49. (defun errexit (s)
  50.   (princ "\nError:  ")
  51.   (princ s)
  52.   (restore)
  53. )
  54.  
  55. (defun fpath (filename / path)
  56.   (if
  57.     (and
  58.       *DT_PATH
  59.       (setq path
  60.         (findfile
  61.           (strcat
  62.             *DT_PATH
  63.             (if (= "\\" (substr *DT_PATH (strlen *DT_PATH) 1)) "" "\\")
  64.             filename
  65.           )
  66.         )
  67.       )
  68.     )
  69.     path
  70.     (findfile filename)
  71.   )
  72. )
  73.  
  74. (defun get_attrib (ent tag / ca t1)
  75.   (while (and ent (setq ent (entnext ent)))
  76.     (setq t1 (entget ent))
  77.     (if 
  78.       (and (= "ATTRIB" (cdr (assoc '0 t1))) (= tag (cdr (assoc '2 t1))))
  79.       (setq ent nil)
  80.       (setq t1 nil)
  81.     )
  82.   )  
  83.   t1
  84. )
  85.  
  86.  
  87. ; ***********************************************
  88. ; ***************  Main Program  ****************
  89. ; ***********************************************
  90.  
  91.   (setq T (not nil))
  92.   (setq oldvar
  93.     (list
  94.       (getvar "CMDECHO")
  95.       (getvar "OSMODE")
  96.       (getvar "REGENMODE")
  97.       (getvar "EXPERT")
  98.     )
  99.   )
  100.   (setq olderr  *error*
  101.         restore edtitlex
  102.         *error* errexit
  103.   )
  104.   (setvar "CMDECHO" 0)
  105.   (setvar "OSMODE" 0)
  106.   (setvar "REGENMODE" 1)
  107.   (setvar "EXPERT" 0)
  108.   (terpri)
  109.   (graphscr)
  110.   (if 
  111.     (or
  112.       (setq as (ssget "X" '((0 . "INSERT") (-3 ("TBLOCK")))))
  113.       (setq as 
  114.         (ssget "X" 
  115.           (list 
  116.             (cons 0 "INSERT") 
  117.             (cons 8 (if *TBLAYER *TBLAYER "TITLE"))
  118.           )
  119.         )
  120.       )
  121.     )
  122.     (progn
  123.       (if (setq t1 (fpath "TBLOCK.LSP")) (load t1))
  124.       (setq p 0)
  125.       (if (< 1 (sslength as))
  126.         (progn
  127.           (setq t1 0)
  128.           (setq il nil)
  129.           (repeat (sslength as)
  130.             (setq il
  131.               (cons
  132.                 (cdr (assoc '10 (entget (ssname as t1))))
  133.                 il
  134.               )
  135.             )
  136.             (setq t1 (1+ t1))
  137.           )
  138.           (setq il (reverse il))
  139.           (if
  140.             (not 
  141.               (setq sp 
  142.                 (getpoint "Pick Insertion Point of Title Block To Edit:  ")
  143.               )
  144.             )
  145.             (setq sp (getvar "LASTPOINT"))
  146.           )
  147.           (setq d (distance (car il) sp))
  148.           (setq t1 1)
  149.           (while (< t1 (length il))
  150.             (if
  151.               (> d (setq t2 (distance (nth t1 il) sp)))
  152.               (progn
  153.                 (setq d t2)
  154.                 (setq p t1)
  155.               )
  156.             )
  157.             (setq t1 (1+ t1))
  158.           )
  159.         )
  160.       )                  
  161.  
  162.  
  163.  
  164. (defun get_attrib_value (ent tag / ca t1 t2)
  165.   (while 
  166.     (and 
  167.       ent 
  168.       (not t2)
  169.       (setq ent (entnext ent))
  170.       (/= "SEQEND" (cdr (assoc '0 (setq t1 (entget ent '("TBLOCK"))))))
  171.     )
  172.     (if 
  173.       (and (= tag (cdr (assoc '2 t1))) (= "ATTRIB" (cdr (assoc '0 t1))))
  174.       (if 
  175.         (not
  176.           (setq t2
  177.             (cdr (assoc '1000 (cdr (assoc "TBLOCK" (cdr (assoc '-3 t1))))))
  178.           )
  179.         )
  180.         (setq t2 (cdr (assoc '1 t1)))
  181.       )          
  182.     )
  183.   )  
  184.   t2
  185. )
  186.       
  187.       
  188.       
  189.       (setq ca (ssname as p))
  190.       (while
  191.         (and 
  192.           (setq ca (entnext ca)) 
  193.           (/= "SEQEND" (cdr (assoc '0 (setq t1 (entget ca '("TBLOCK"))))))
  194.         )
  195.         (and
  196.           (= "ATTRIB" (cdr (assoc '0 t1)))
  197.           (setq t2
  198.             (cdr (assoc '1000 (cdr (assoc "TBLOCK" (cdr (assoc '-3 t1))))))
  199.           )
  200.           (entmod
  201.             (subst
  202.               (cons '1 t2)
  203.               (assoc '1 t1)
  204.               t1
  205.             )
  206.           )
  207.         )
  208.       )
  209.       (setq ca (ssname as p))
  210.       (command "_DDATTE" ca)
  211.       (setq *TBATTRIB ca)
  212.       (if (/= 0 (cdr (assoc '66 (entget ca))))
  213.         (progn
  214.           (while
  215.             (and (setq ca (entnext ca)) (setq t1 (entget ca)))
  216.             (and
  217.               (= "ATTRIB" (cdr (assoc '0 t1)))
  218.               (= "==" (substr (cdr (assoc '1 t1)) 1 2))
  219.               (entmod
  220.                 (subst
  221.                   (cons '1 (eval (read (substr (cdr (assoc '1 t1)) 3))))
  222.                   (assoc '1 t1)
  223.                   t1
  224.                 )
  225.               )
  226.             )
  227.           )
  228.           (entupd (ssname as p))
  229.         )
  230.       )
  231.     )
  232.     (alert "*** You Must Insert a Title Block Before Attempting to Edit ***")
  233.   )
  234.   (restore)
  235. )
  236.