home *** CD-ROM | disk | FTP | other *** search
/ Share Gallery 1 / share_gal_1.zip / share_gal_1 / GR / GR505.ZIP / LSP.EXE / FRACMOD.LSP < prev    next >
Lisp/Scheme  |  1988-07-26  |  6KB  |  125 lines

  1.  
  2. ; FRACMOD command - swaps a single char. fraction for 4 char. fraction.
  3. ;                   It's a modified CHGTEXT command and REQUIRES Rel. 9.
  4. ;
  5. ;        *** This command requires that text style on the selected  ***
  6. ;        *** layer be defined in the .dwg using the fonts "DIMPLEX" ***
  7. ;        *** or "DOMPLEX" (or another font w/ a - g setup as frac-  ***
  8. ;        *** tions). DIMPLEX & DOMPLEX are incl'd in the .arc file. ***
  9. ;                   The fonts are modified ACAD ver.2.6 SIMPLEX and
  10. ;                   COMPLEX. The fractions 1/8 to 7/8 (in 1/8 increments)
  11. ;                   have been substituted for the lowercase letters a - g.
  12. ;                   We use all CAP's in our dimensioning and consider it
  13. ;                   a minor miracle if the contractors can hold 1/8 inch
  14. ;                   tolerences. You can modify the .shp files and the 
  15. ;                   look-up table in FRACMOD to suit your needs.
  16. ;
  17. ;                   Run the command CHGSTYLE first if you need to change
  18. ;                   the text style to one that uses a font w/fractions.
  19. ;                   
  20. ;
  21. ; SWITCH - swaps NewString for OldString in the FRACMOD command.
  22.  
  23. (defun SWITCH (ns)
  24.   (setq s (strcat (substr s 1 (1- si)) ns
  25.                   (substr s (+ si osl))))
  26.   (setq chf t)    ; Found old string
  27.   (setq si (+ si nsl))
  28. )
  29.  
  30. (defun C:FRACMOD (/ p cl n e os as ns st s nsl osl sl si chf chm)
  31.   (terpri)
  32.   (if (setq osl (entsel "\n  Select an item on the layer to be modified : "))
  33.     ;then#1
  34.      (progn                               ;progn#t1
  35.      (setq osl (cdr (assoc 8 (entget (car osl)))))
  36.      (setq chm 0 p (ssget "X" (list (cons 0 "TEXT")(cons 8 osl))))
  37.                                           ;Selects all text on layer ARDIM
  38.      (if p                                ;if#2
  39.         (progn              ;progn#t2      If any objects selected
  40.         (setq osl 4 nsl 1)                ;Recycles the variable osl
  41.         (setq cl 0 n (sslength p))        ;Set the counters for size of SSet
  42.         (while (< cl n)                   ;while#1  For each selected object...
  43.            (progn                         ;progn#w1
  44.            (setq e (entget (ssname p cl)))         ;Get next entity in SSet
  45.            (setq chf nil si 1)                     ;Set a marker and a counter
  46.            (setq s (cdr (setq as (assoc 1 e))))    ; Get the text
  47.            (while (= osl (setq sl (strlen (setq st (substr s si osl)))));while#2
  48.               (cond                       ;cond#1   Tests for cond of
  49.               ((= st " 1/8")(switch "a"))          ;several common arch.
  50.               ((= st " 1/4")(switch "b"))          ;fractions used by the
  51.               ((= st " 3/8")(switch "c"))          ;dim cmd and calls SWITCH
  52.               ((= st " 1/2")(switch "d"))          ;to substitute a single
  53.               ((= st " 5/8")(switch "e"))          ;char frac for dim's
  54.               ((= st " 3/4")(switch "f"))          ;4 char frac's
  55.               ((= st " 7/8")(switch "g"))
  56.               )                                    ;end cond#1
  57.               (setq si (1+ si))
  58.            )                                       ;end while#2
  59.            (if chf                                 ;if#3 If there was a SWITCH
  60.               (progn                 ;progn#t3           make it permanent.
  61.               (setq e (subst (cons 1 s) as e))
  62.               (entmod e)                           ; Modify the TEXT entity
  63.               (setq chm (1+ chm))
  64.               )                                    ;end progn#t3
  65.            )                                       ;end if#3
  66.            (setq cl (1+ cl))
  67.            )                                       ;end progn#w1
  68.         )                                          ;end while#1
  69.       )                                            ;end progn #t2
  70.      ))                                            ;end if#2 & progn#t1
  71.      ;else#1
  72.      (progn (terpri)(prompt "\nMissed!")(C:fracmod))
  73.   )                                                ;end if#1
  74.    (princ)                                         ;exit cleanly
  75. )
  76.  
  77. ; CHGSTYLE -  changes the text style of all text on a user selected layer
  78. ;             to a user spcified text style. This requires that the text
  79. ;             style be defined.
  80. ;
  81. ; Variables Schedule
  82. ;    dl      - layer selected to be modified.
  83. ;    ts      - new text style
  84. ;    c       - selection set of text ent's on dimlyr.
  85. ;    d       - index marker for position in sel. set.
  86. ;    e       - # of entities in the selection set.
  87. ;    f       - variable assigned to each entity in sel. set.
  88.  
  89. (defun C:CHGSTYLE (/ dl ts c d e f)
  90.   (terpri)
  91.   (setq dl (entsel "\nselect item on layer to be modified :"))
  92.   (terpri)
  93.   (if dl                                ;if#1
  94.      ;then#1
  95.      (progn                             ;progn#t1
  96.      (setq dl (cdr (assoc 8 (entget (car dl)))))
  97.      (if (tblsearch "STYLE" (setq ts (strcase (getstring "\nNew style : "))))
  98.         ;then#2
  99.         (progn                          ;progn#t2
  100.         (setq c (ssget "X" (list (cons 0 "TEXT")(cons 8 dl))))
  101.         (setq d 0 e (sslength c))
  102.         (while (< d e)               ;while#1
  103.            (progn                    ;progn#w1
  104.            (setq f (entget (ssname c d)))
  105.            (setq f (subst (cons 7 ts) (assoc 7 f) f))
  106.            (entmod f)
  107.            (setq d (1+ d))
  108.            )                         ;end progn#w1
  109.         )                            ;end while#1
  110.         (prompt "\nAll done.")
  111.         )                              ;end progn#t2
  112.        ;else#2
  113.         (progn
  114.         (terpri)
  115.         (prompt (strcat "\nText style " ts " is not defined in this drawing."))
  116.         )
  117.      ))                                 ;end if#2 & progn#t1
  118.      ;else#1
  119.      (progn (prompt "\nMissed!")(C:chgstyle))
  120.   )                                     ;end if#1
  121.   (princ)                               ;exit cleanly
  122. )
  123.  
  124.