home *** CD-ROM | disk | FTP | other *** search
/ Share Gallery 1 / share_gal_1.zip / share_gal_1 / GR / GR505.ZIP / LSP.EXE / CHGSIZE.LSP < prev    next >
Lisp/Scheme  |  1989-01-03  |  5KB  |  206 lines

  1. ; CHGSIZE.LSP
  2. ; Change various text properties.
  3. ; Part of the Text Utility Kit Version 1.0
  4. ; Copyright 1989 Alacrity
  5.  
  6. ; Alacrity
  7. ; 12405 SE 25th St
  8. ; Bellevue WA 98005
  9. ; Voice: (206)746-0680
  10. ; BBS: (206)643-5477
  11. ; CompuServe: 73417,1756
  12.  
  13. ; Shareware software, If you use -- Please don't abuse!
  14.  
  15. (princ "\nCHGSIZE.LSP - (c)1989 Alacrity\n")
  16.  
  17. ;-----------------------
  18. ; Filter Selection Sets
  19. ;-----------------------
  20. (defun ssfilter (ss lst kill / len i group data match ename elist)
  21.   (princ "\nFiltering selection set...")
  22.   (setq i 0 group (car lst) data (cdr lst))
  23.   (while (ssname ss i)
  24.     (setq ename (ssname ss i) elist (entget ename)
  25.           match (== data (cdr (assoc group elist))))
  26.     (if (= kill match)
  27.       (ssdel ename ss)
  28.       (setq i (1+ i))
  29.     )
  30.   )
  31.   (if (ssname ss 0) ss nil)
  32. )
  33.  
  34. ;-------------
  35. ; Fuzzy Equal
  36. ;-------------
  37. (defun == (a b)
  38.   (if (member (type a) '(INT REAL)) (> 1.0E-6 (abs (- a b))) (= a b))
  39. )
  40.  
  41. (defun C:CHGSIZE (/ ss ename elist chglst pick ename layer style
  42.                     obliq width rot key group lst key getkey)
  43.   ;------------------------
  44.   ; Pick attribute of text
  45.   ;------------------------
  46.   (defun pick (group)
  47.     (while 
  48.       (and
  49.         (setq ename (car (entsel)))
  50.         (setq elist (entget ename))
  51.         (/= (cdr (assoc 0 elist)) "TEXT")
  52.       )
  53.       (princ "\nInvalid ...")
  54.     )
  55.     (apply
  56.       'princ
  57.       (list "\nPicked " (strcase key T) " is : " (cdr (assoc group elist)))
  58.     )
  59.   )
  60.   ;---------
  61.   ; Get Key
  62.   ;---------
  63.   (defun getkey (msg)
  64.     (initget "Style Layer Height Rot Width Obliq")
  65.     (setq key (getkword (strcat "\n" msg " Style/Height/Rot/Width/Obliq/Layer: ")))
  66.   )
  67.   ;----------------
  68.   ; Get Style Name
  69.   ;----------------
  70.   (defun style (msg)
  71.     (while
  72.       (not
  73.         (cond
  74.           ((= (setq key (strcase (getstring msg))) "P") (setq key (pick 7)))
  75.           ((tblsearch "style" key) T)
  76.           (T nil)
  77.         )
  78.       )
  79.       (princ "\nInvalid style name.")
  80.     )
  81.     (cons 7 key)
  82.   )
  83.   ;----------------
  84.   ; Get Layer Name
  85.   ;----------------
  86.   (defun layer (msg)
  87.     (while
  88.       (not
  89.         (cond
  90.           ((= (setq key (strcase (getstring msg))) "P") (setq key (pick 8)))
  91.           ((tblsearch "layer" key) T)
  92.           (T nil)
  93.         )
  94.       )
  95.       (princ "\nInvalid layer name.")
  96.     )
  97.     (cons 8 key)
  98.   )
  99.   ;------------
  100.   ; Get Height
  101.   ;------------
  102.   (defun height (msg)
  103.     (initget 7 "Pick")
  104.     (setq key (getdist msg))
  105.     (if (= key "Pick") (setq key (pick 40)))
  106.     (cons 40 key)
  107.   )
  108.   ;--------------
  109.   ; Get Rotation
  110.   ;--------------
  111.   (defun rot (msg)
  112.     (initget 1 "Pick")
  113.     (setq key (getangle msg))
  114.     (if (= key "Pick") (setq key (pick 50)))
  115.     (cons 50 key)
  116.   )
  117.   ;-----------
  118.   ; Get Width
  119.   ;-----------
  120.   (defun width (msg)
  121.     (initget 1 "Pick")
  122.     (setq key (getreal msg))
  123.     (if (= key "Pick") (setq key (pick 41)))
  124.     (cons 41 key)
  125.   )
  126.   ;-----------------
  127.   ; Get Obliq angle
  128.   ;-----------------
  129.   (defun obliq (msg)
  130.     (while
  131.       (progn
  132.         (not (initget 1 "Pick"))
  133.         (setq key (getorient msg))
  134.         (cond
  135.           ((and (> key 1.483530) (< key 4.799655))
  136.             (princ "\nAngle too large.")
  137.           )
  138.           ((= key "Pick")
  139.             (not (setq key (pick 51)))
  140.           )
  141.         )
  142.       )
  143.     )
  144.     (cons 51 key)
  145.   )
  146.   ;-----------------------------
  147.   ; Get TEXT entities to change
  148.   ;-----------------------------
  149.   (cond
  150.     ((setq ss (ssget))
  151.       (setq ss (ssfilter ss '(0 . "TEXT") nil))
  152.     )
  153.     (T
  154.       (princ "\nSelecting all TEXT in drawing.")
  155.       (setq ss (ssget "X" '((0 . "TEXT"))))
  156.     )
  157.   )
  158.   ;--------------------------
  159.   ; Specify MATCH parameters
  160.   ;--------------------------
  161.   (while
  162.     (and
  163.       (princ (strcat "\n" (itoa (sslength ss)) " entities selected."))
  164.       (ssname ss 0)
  165.       (setq key (getkey "MATCH"))
  166.     )
  167.     (setq msg (strcat "\nEnter " (strcase key) " to match (or Pick): ")
  168.           key (eval (list (read key) msg))
  169.           ss (ssfilter ss key nil)
  170.     )
  171.   )
  172.   ;---------------------------
  173.   ; Specify CHANGE parameters
  174.   ;---------------------------
  175.   (if ss
  176.     (while
  177.       (setq key (getkey "CHANGE"))
  178.       (setq msg (strcat "\nEnter new " (strcase key) " (or Pick): "))
  179.       (setq key (eval (list (read key) msg)))
  180.       (setq chglst (append (list key) chglst))
  181.     )
  182.   )
  183.   ;----------------------
  184.   ; Change TEXT entities
  185.   ;----------------------
  186.   (if (and ss chglst)
  187.     (progn
  188.       (setq i 0)
  189.       (while (setq ename (ssname ss i))
  190.         (setq elist (entget ename) i (1+ i))
  191.         (foreach
  192.           group
  193.           chglst
  194.           (setq elist (subst group (assoc (car group) elist) elist))
  195.         )
  196.         (entmod elist)
  197.       )
  198.       (princ (strcat "\n" (itoa (sslength ss)) " entities changed."))
  199.     )
  200.   )
  201.   ; All done
  202.   (princ)
  203. )
  204.  
  205. ; End Of File
  206.