Jump to content

input triggering output


mbrandt5

Recommended Posts

I'm wondering how I can make one variable determine another variable

 

 

I'd like to be able to alter this code have old string run through all fractions

then have new string change to all of these stacked diagonal fractions

 

So 1/4 would turn into this

{\H0.75x;\S1#4;}

and

So 3/8 would turn into this

{\H0.75x;\S3#8;}

 

 

Without requiring a user to input string

 

 

 

 

(defun c:superstr()
   (setq olsosmode (getvar "OSMODE"))
   (setvar "OSMODE" 0)
   (setq p (ssget))  
   (if p
(progn
           (setq osl (strlen (setq os (getstring "\nOld string: " t))))
           (setq nsl (strlen (setq ns (getstring "\nNew string: " t))))
    (setq l 0 chm 0 n (sslength p))
    (setq adj
 (cond
     ((/= osl nsl) (- nsl osl))
     (T nsl)
 )
    )
(while (< l n)                  
    (setq d (entget (setq e (ssname p l))))
    (if (and (= (atext 0) "INSERT")(= (atext 66) 1))
 (progn
     (setq e (entnext e))
     (while e
  (setq d (entget e))
  (cond
      ((= (atext 0) "ATTRIB")
   (setq chf nil si 1)
   (setq s (cdr (setq as (assoc 1 d))))
   (while (= osl (setq sl (strlen
       (setq st (substr s si osl)))))
       (cond
    ((= st os)
        (setq s (strcat (substr s 1 (1- si)) ns
        (substr s (+ si osl))))
        (setq chf t)
        (setq si (+ si adj))
    )
       )
   (setq si (1+ si))
      )
      (if chf
   (progn       
       (setq d (subst (cons 1 s) as d))
       (entmod d)       
       (entupd e)       
       (setq chm (1+ chm))
   )
      )
      (setq e (entnext e))
      )
      ((= (atext 0) "SEQEND")
   (setq e nil))
      (T (setq e (entnext e)))
                       )
     )
 )
    )
           (if (= "MTEXT"            ; Look for MTEXT entity type (group 0)
              (cdr (assoc 0 (setq e (entget (ssname p l))))))
                 (progn
                    (setq chf nil si 1)
                    (setq s (cdr (setq as (assoc 1 e))))
                    (while (= osl (setq sl (strlen
                       (setq st (substr s si osl)))))
                       (if (= st os)
                          (progn
                             (setq s (strcat (substr s 1 (1- si)) ns
                                       (substr s (+ si osl))))
                          (setq chf t) ; Found old string
                       (setq si (+ si nsl))
                     )
                     (setq si (1+ si))
                 )
              )

Link to comment
Share on other sites

I would start by breaking your code into defuns your ssget can get basicly anything, then use a cond on the object type TEXT, MTEXT or Blocks, others ignore. This way you just work with 1 defun rather than a mega IF. Again a seperate defun that is called once you have the text string has a series of conds 1/8 1/4 3/8 1/2 etc and sets the correct mtext string. What I am saying is you can have defuns called inside defuns.

 

defun change text
defun ssget stuff
defun what is it
defun text option convert to mtext, defun change text 
defun mtext get value, defun change text
defun insert get attributes, defun change text
program starts here

Link to comment
Share on other sites

This bit of code would be useful to convert the old string to what you are looking for:

(if (vl-string-search "/" os)
 (setq ns (strcat "{\\H0.75x;\\S" (vl-string-subst "#" "/" os 0) ";}")))

Link to comment
Share on other sites

Sorry I just realized that i didn't post the full code originally

 

(defun c:superstr()
   (setq olsosmode (getvar "OSMODE"))
   (setvar "OSMODE" 0)
   (setq p (ssget))  
   (if p
(progn
           (setq osl (strlen (setq os (getstring "\nOld string: " t))))
           (setq nsl (strlen (setq ns (getstring "\nNew string: " t))))
    (setq l 0 chm 0 n (sslength p))
    (setq adj
 (cond
     ((/= osl nsl) (- nsl osl))
     (T nsl)
 )
    )
(while (< l n)                  
    (setq d (entget (setq e (ssname p l))))
    (if (and (= (atext 0) "INSERT")(= (atext 66) 1))
 (progn
     (setq e (entnext e))
     (while e
  (setq d (entget e))
  (cond
      ((= (atext 0) "ATTRIB")
   (setq chf nil si 1)
   (setq s (cdr (setq as (assoc 1 d))))
   (while (= osl (setq sl (strlen
       (setq st (substr s si osl)))))
       (cond
    ((= st os)
        (setq s (strcat (substr s 1 (1- si)) ns
        (substr s (+ si osl))))
        (setq chf t)
        (setq si (+ si adj))
    )
       )
   (setq si (1+ si))
      )
      (if chf
   (progn       
       (setq d (subst (cons 1 s) as d))
       (entmod d)       
       (entupd e)       
       (setq chm (1+ chm))
   )
      )
      (setq e (entnext e))
      )
      ((= (atext 0) "SEQEND")
   (setq e nil))
      (T (setq e (entnext e)))
                       )
     )
 )
    )
           (if (= "MTEXT"            ; Look for MTEXT entity type (group 0)
              (cdr (assoc 0 (setq e (entget (ssname p l))))))
                 (progn
                    (setq chf nil si 1)
                    (setq s (cdr (setq as (assoc 1 e))))
                    (while (= osl (setq sl (strlen
                       (setq st (substr s si osl)))))
                       (if (= st os)
                          (progn
                             (setq s (strcat (substr s 1 (1- si)) ns
                                       (substr s (+ si osl))))
                          (setq chf t) ; Found old string
                       (setq si (+ si nsl))
                     )
                     (setq si (1+ si))
                 )
              )
              (if chf (progn        ; Substitute new string for old
                 (setq e (subst (cons 1 s) as e))
                 (entmod e)         ; Modify the TEXT entity
                 (setq chm (1+ chm))
              ))
           )
        )
    (if (= "DIMENSION"            ; Look for DIMENSION entity type (group 0)
              (cdr (assoc 0 (setq e (entget (ssname p l))))))
                 (progn
                    (setq chf nil si 1)
                    (setq s (cdr (setq as (assoc 1 e))))
                    (while (= osl (setq sl (strlen
                       (setq st (substr s si osl)))))
                       (if (= st os)
                          (progn
                             (setq s (strcat (substr s 1 (1- si)) ns
                                       (substr s (+ si osl))))
                          (setq chf t) ; Found old string
                       (setq si (+ si nsl))
                     )
                     (setq si (1+ si))
                 )
              )
              (if chf (progn        ; Substitute new string for old
                 (setq e (subst (cons 1 s) as e))
                 (entmod e)         ; Modify the TEXT entity
                 (setq chm (1+ chm))
              ))
           )
        )
    (if (= "TEXT"            ; Look for TEXT entity type (group 0)
              (cdr (assoc 0 (setq e (entget (ssname p l))))))
                 (progn
                    (setq chf nil si 1)
                    (setq s (cdr (setq as (assoc 1 e))))
                    (while (= osl (setq sl (strlen
                       (setq st (substr s si osl)))))
                       (if (= st os)
                          (progn
                             (setq s (strcat (substr s 1 (1- si)) ns
                                       (substr s (+ si osl))))
                          (setq chf t) ; Found old string
                       (setq si (+ si nsl))
                     )
                     (setq si (1+ si))
                 )
              )
              (if chf (progn        ; Substitute new string for old
                 (setq e (subst (cons 1 s) as e))
                 (entmod e)         ; Modify the TEXT entity
                 (setq chm (1+ chm))
              ))
           )
        )
    (setq l (1+ l))
)
)
   )
   (if (> chm 1)
      (princ (strcat "\nUpdated " (itoa chm) " text strings"))
      (princ (strcat "\nUpdated " (itoa chm) " text string"))
   )
   (setvar "OSMODE" oldosmode)
   (terpri)
)
;
(defun atext (num)
  (cdr (assoc num d))
)

 

Also, I apologize for my poor coding skills but I'm not sure exactly what I would delete or where I would add this replacement function you've given me?

 

(if (vl-string-search "/" os)
 (setq ns (strcat "{\\H0.75x;\\S" (vl-string-subst "#" "/" os 0) ";}")))

 

Anyone willing to assist

Link to comment
Share on other sites

So I figured out how to add the code you supplied me with to make the entered fraction replace with the stacked version

 

 

Here Is The Updated Code:

(defun c:superstr()
   (setq olsosmode (getvar "OSMODE"))
   (setvar "OSMODE" 0)
   (setq p (ssget))  
   (if p
(progn
           (setq osl (strlen (setq os (getstring "\nOld string: " t))))
           (setq nsl (strlen (setq ns os)))
     (if (vl-string-search "/" os)
 (setq ns (strcat "{\\H0.75x;\\S" (vl-string-subst "#" "/" os 0) ";}")))
    (setq l 0 chm 0 n (sslength p))
    (setq adj
 (cond
     ((/= osl nsl) (- nsl osl))
     (T nsl)
 )
    )
(while (< l n)                  
    (setq d (entget (setq e (ssname p l))))
    (if (and (= (atext 0) "INSERT")(= (atext 66) 1))
 (progn
     (setq e (entnext e))
     (while e
  (setq d (entget e))
  (cond
      ((= (atext 0) "ATTRIB")
   (setq chf nil si 1)
   (setq s (cdr (setq as (assoc 1 d))))
   (while (= osl (setq sl (strlen
       (setq st (substr s si osl)))))
       (cond
    ((= st os)
        (setq s (strcat (substr s 1 (1- si)) ns
        (substr s (+ si osl))))
        (setq chf t)
        (setq si (+ si adj))
    )
       )
   (setq si (1+ si))
      )
      (if chf
   (progn       
       (setq d (subst (cons 1 s) as d))
       (entmod d)       
       (entupd e)       
       (setq chm (1+ chm))
   )
      )
      (setq e (entnext e))
      )
      ((= (atext 0) "SEQEND")
   (setq e nil))
      (T (setq e (entnext e)))
                       )
     )
 )
    )
           (if (= "MTEXT"            ; Look for MTEXT entity type (group 0)
              (cdr (assoc 0 (setq e (entget (ssname p l))))))
                 (progn
                    (setq chf nil si 1)
                    (setq s (cdr (setq as (assoc 1 e))))
                    (while (= osl (setq sl (strlen
                       (setq st (substr s si osl)))))
                       (if (= st os)
                          (progn
                             (setq s (strcat (substr s 1 (1- si)) ns
                                       (substr s (+ si osl))))
                          (setq chf t) ; Found old string
                       (setq si (+ si nsl))
                     )
                     (setq si (1+ si))
                 )
              )
              (if chf (progn        ; Substitute new string for old
                 (setq e (subst (cons 1 s) as e))
                 (entmod e)         ; Modify the TEXT entity
                 (setq chm (1+ chm))
              ))
           )
        )
    (if (= "DIMENSION"            ; Look for DIMENSION entity type (group 0)
              (cdr (assoc 0 (setq e (entget (ssname p l))))))
                 (progn
                    (setq chf nil si 1)
                    (setq s (cdr (setq as (assoc 1 e))))
                    (while (= osl (setq sl (strlen
                       (setq st (substr s si osl)))))
                       (if (= st os)
                          (progn
                             (setq s (strcat (substr s 1 (1- si)) ns
                                       (substr s (+ si osl))))
                          (setq chf t) ; Found old string
                       (setq si (+ si nsl))
                     )
                     (setq si (1+ si))
                 )
              )
              (if chf (progn        ; Substitute new string for old
                 (setq e (subst (cons 1 s) as e))
                 (entmod e)         ; Modify the TEXT entity
                 (setq chm (1+ chm))
              ))
           )
        )
    (if (= "TEXT"            ; Look for TEXT entity type (group 0)
              (cdr (assoc 0 (setq e (entget (ssname p l))))))
                 (progn
                    (setq chf nil si 1)
                    (setq s (cdr (setq as (assoc 1 e))))
                    (while (= osl (setq sl (strlen
                       (setq st (substr s si osl)))))
                       (if (= st os)
                          (progn
                             (setq s (strcat (substr s 1 (1- si)) ns
                                       (substr s (+ si osl))))
                          (setq chf t) ; Found old string
                       (setq si (+ si nsl))
                     )
                     (setq si (1+ si))
                 )
              )
              (if chf (progn        ; Substitute new string for old
                 (setq e (subst (cons 1 s) as e))
                 (entmod e)         ; Modify the TEXT entity
                 (setq chm (1+ chm))
              ))
           )
        )
    (setq l (1+ l))
)
)
   )
   (if (> chm 1)
      (princ (strcat "\nUpdated " (itoa chm) " text strings"))
      (princ (strcat "\nUpdated " (itoa chm) " text string"))
   )
   (setvar "OSMODE" oldosmode)
   (terpri)
)
;
(defun atext (num)
  (cdr (assoc num d))
)

 

 

Now, I looking for a way to have the all fractions searched for instead of having a string entered...

 

 

Is there any way that I can set os to multiple fractions at once?

 

 

Or am I going to have to set up some sort of continuation from 1/16th to 15/16th, seeing as I'm only requiring the 16ths to change...

Edited by mbrandt5
Link to comment
Share on other sites

So I got one fraction to replace with a stacked diagonal... now i just need the other 14

 

Please help me :unsure: ...lol

 

 

(defun c:superstr()
   (setq olsosmode (getvar "OSMODE"))
   (setvar "OSMODE" 0)
   (setq p (ssget))  
   (if p
(progn
           (setq osl (strlen (setq os "1/4")))
           (setq nsl (strlen (setq ns os)))
     (if (vl-string-search "/" os)
 (setq ns (strcat "{\\H0.75x;\\S" (vl-string-subst "#" "/" os 0) ";}")))     (setq l 0 chm 0 n (sslength p))
    (setq adj
 (cond
     ((/= osl nsl) (- nsl osl))
     (T nsl)
 )
    )
(while (< l n)                  
    (setq d (entget (setq e (ssname p l))))
    (if (and (= (atext 0) "INSERT")(= (atext 66) 1))
 (progn
     (setq e (entnext e))
     (while e
  (setq d (entget e))
  (cond
      ((= (atext 0) "ATTRIB")
   (setq chf nil si 1)
   (setq s (cdr (setq as (assoc 1 d))))
   (while (= osl (setq sl (strlen
       (setq st (substr s si osl)))))
       (cond
    ((= st os)
        (setq s (strcat (substr s 1 (1- si)) ns
        (substr s (+ si osl))))
        (setq chf t)
        (setq si (+ si adj))
    )
       )
   (setq si (1+ si))
      )
      (if chf
   (progn       
       (setq d (subst (cons 1 s) as d))
       (entmod d)       
       (entupd e)       
       (setq chm (1+ chm))
   )
      )
      (setq e (entnext e))
      )
      ((= (atext 0) "SEQEND")
   (setq e nil))
      (T (setq e (entnext e)))
                       )
     )
 )
    )
           (if (= "MTEXT"            ; Look for MTEXT entity type (group 0)
              (cdr (assoc 0 (setq e (entget (ssname p l))))))
                 (progn
                    (setq chf nil si 1)
                    (setq s (cdr (setq as (assoc 1 e))))
                    (while (= osl (setq sl (strlen
                       (setq st (substr s si osl)))))
                       (if (= st os)
                          (progn
                             (setq s (strcat (substr s 1 (1- si)) ns
                                       (substr s (+ si osl))))
                          (setq chf t) ; Found old string
                       (setq si (+ si nsl))
                     )
                     (setq si (1+ si))
                 )
              )
              (if chf (progn        ; Substitute new string for old
                 (setq e (subst (cons 1 s) as e))
                 (entmod e)         ; Modify the TEXT entity
                 (setq chm (1+ chm))
              ))
           )
        )
    (if (= "DIMENSION"            ; Look for DIMENSION entity type (group 0)
              (cdr (assoc 0 (setq e (entget (ssname p l))))))
                 (progn
                    (setq chf nil si 1)
                    (setq s (cdr (setq as (assoc 1 e))))
                    (while (= osl (setq sl (strlen
                       (setq st (substr s si osl)))))
                       (if (= st os)
                          (progn
                             (setq s (strcat (substr s 1 (1- si)) ns
                                       (substr s (+ si osl))))
                          (setq chf t) ; Found old string
                       (setq si (+ si nsl))
                     )
                     (setq si (1+ si))
                 )
              )
              (if chf (progn        ; Substitute new string for old
                 (setq e (subst (cons 1 s) as e))
                 (entmod e)         ; Modify the TEXT entity
                 (setq chm (1+ chm))
              ))
           )
        )
    (if (= "TEXT"            ; Look for TEXT entity type (group 0)
              (cdr (assoc 0 (setq e (entget (ssname p l))))))
                 (progn
                    (setq chf nil si 1)
                    (setq s (cdr (setq as (assoc 1 e))))
                    (while (= osl (setq sl (strlen
                       (setq st (substr s si osl)))))
                       (if (= st os)
                          (progn
                             (setq s (strcat (substr s 1 (1- si)) ns
                                       (substr s (+ si osl))))
                          (setq chf t) ; Found old string
                       (setq si (+ si nsl))
                     )
                     (setq si (1+ si))
                 )
              )
              (if chf (progn        ; Substitute new string for old
                 (setq e (subst (cons 1 s) as e))
                 (entmod e)         ; Modify the TEXT entity
                 (setq chm (1+ chm))
              ))
           )
        )
    (setq l (1+ l))
)
)
   )
   (if (> chm 1)
      (princ (strcat "\nUpdated " (itoa chm) " text strings"))
      (princ (strcat "\nUpdated " (itoa chm) " text string"))
   )
   (setvar "OSMODE" oldosmode)
   (terpri)
)
;
(defun atext (num)
  (cdr (assoc num d))
)

Link to comment
Share on other sites

I've tried applying a list using mapcar with no success getting a result of bad variable...will someone let me know what i'm doing wrong and help fix it?

 

(defun c:superstr()
   (setq olsosmode (getvar "OSMODE"))
   (setvar "OSMODE" 0)
   (setq p (ssget)) 
   (if p
(progn
           (setq osl (strlen (setq os (mapcar 'yourfun stringlist))))
           (setq nsl (strlen (setq ns os)))
     (if (vl-string-search "/" os)
 (setq ns (strcat "{\\H0.75x;\\S" (vl-string-subst "#" "/" os 0) ";}")))     (setq l 0 chm 0 n (sslength p))
    (setq adj
 (cond
     ((/= osl nsl) (- nsl osl))
     (T nsl)
 )
    )
(while (< l n)                  
    (setq d (entget (setq e (ssname p l))))
    (if (and (= (atext 0) "INSERT")(= (atext 66) 1))
 (progn
     (setq e (entnext e))
     (while e
  (setq d (entget e))
  (cond
      ((= (atext 0) "ATTRIB")
   (setq chf nil si 1)
   (setq s (cdr (setq as (assoc 1 d))))
   (while (= osl (setq sl (strlen
       (setq st (substr s si osl)))))
       (cond
    ((= st os)
        (setq s (strcat (substr s 1 (1- si)) ns
        (substr s (+ si osl))))
        (setq chf t)
        (setq si (+ si adj))
    )
       )
   (setq si (1+ si))
      )
      (if chf
   (progn       
       (setq d (subst (cons 1 s) as d))
       (entmod d)       
       (entupd e)       
       (setq chm (1+ chm))
   )
      )
      (setq e (entnext e))
      )
      ((= (atext 0) "SEQEND")
   (setq e nil))
      (T (setq e (entnext e)))
                       )
     )
 )
    )
           (if (= "MTEXT"            ; Look for MTEXT entity type (group 0)
              (cdr (assoc 0 (setq e (entget (ssname p l))))))
                 (progn
                    (setq chf nil si 1)
                    (setq s (cdr (setq as (assoc 1 e))))
                    (while (= osl (setq sl (strlen
                       (setq st (substr s si osl)))))
                       (if (= st os)
                          (progn
                             (setq s (strcat (substr s 1 (1- si)) ns
                                       (substr s (+ si osl))))
                          (setq chf t) ; Found old string
                       (setq si (+ si nsl))
                     )
                     (setq si (1+ si))
                 )
              )
              (if chf (progn        ; Substitute new string for old
                 (setq e (subst (cons 1 s) as e))
                 (entmod e)         ; Modify the TEXT entity
                 (setq chm (1+ chm))
              ))
           )
        )
    (if (= "DIMENSION"            ; Look for DIMENSION entity type (group 0)
              (cdr (assoc 0 (setq e (entget (ssname p l))))))
                 (progn
                    (setq chf nil si 1)
                    (setq s (cdr (setq as (assoc 1 e))))
                    (while (= osl (setq sl (strlen
                       (setq st (substr s si osl)))))
                       (if (= st os)
                          (progn
                             (setq s (strcat (substr s 1 (1- si)) ns
                                       (substr s (+ si osl))))
                          (setq chf t) ; Found old string
                       (setq si (+ si nsl))
                     )
                     (setq si (1+ si))
                 )
              )
              (if chf (progn        ; Substitute new string for old
                 (setq e (subst (cons 1 s) as e))
                 (entmod e)         ; Modify the TEXT entity
                 (setq chm (1+ chm))
              ))
           )
        )
    (if (= "TEXT"            ; Look for TEXT entity type (group 0)
              (cdr (assoc 0 (setq e (entget (ssname p l))))))
                 (progn
                    (setq chf nil si 1)
                    (setq s (cdr (setq as (assoc 1 e))))
                    (while (= osl (setq sl (strlen
                       (setq st (substr s si osl)))))
                       (if (= st os)
                          (progn
                             (setq s (strcat (substr s 1 (1- si)) ns
                                       (substr s (+ si osl))))
                          (setq chf t) ; Found old string
                       (setq si (+ si nsl))
                     )
                     (setq si (1+ si))
                 )
              )
              (if chf (progn        ; Substitute new string for old
                 (setq e (subst (cons 1 s) as e))
                 (entmod e)         ; Modify the TEXT entity
                 (setq chm (1+ chm))
              ))
           )
        )
    (setq l (1+ l))
)
)
   )
   (if (> chm 1)
      (princ (strcat "\nUpdated " (itoa chm) " text strings"))
      (princ (strcat "\nUpdated " (itoa chm) " text string"))
   )
   (setvar "OSMODE" oldosmode)
   (terpri)
)
;
(defun atext (num)
  (cdr (assoc num d))
)
;
(defun yourfun (os)
(setq stringlist '(list "1/4" "1/2"))
)

Link to comment
Share on other sites

(defun c:superstr()
   (setq p (ssget))  
   (if p
(progn
          (setq osl (strlen (setq os " 1/4")))
           (setq nsl (strlen (setq ns os)))       
     (if (vl-string-search "/" os)
 (setq ns (strcat "{\\H0.75x;\\S" (vl-string-subst "#" "/" os 0) ";}")))
 (setq ns (vl-string-subst "" " " ns))     
 (setq l 0 chm 0 n (sslength p))
    (setq adj
 (cond
     ((/= osl nsl) (- nsl osl))
     (T nsl)
 )
    )
(while (< l n)                  
    (setq d (entget (setq e (ssname p l))))
    (if (and (= (atext 0) "INSERT")(= (atext 66) 1))
 (progn
     (setq e (entnext e))
     (while e
  (setq d (entget e))
  (cond
      ((= (atext 0) "ATTRIB")
   (setq chf nil si 1)
   (setq s (cdr (setq as (assoc 1 d))))
   (while (= osl (setq sl (strlen
       (setq st (substr s si osl)))))
       (cond
    ((= st os)
        (setq s (strcat (substr s 1 (1- si)) ns
        (substr s (+ si osl))))
        (setq chf t)
        (setq si (+ si adj))
    )
       )
   (setq si (1+ si))
      )
      (if chf
   (progn       
       (setq d (subst (cons 1 s) as d))
       (entmod d)       
       (entupd e)       
       (setq chm (1+ chm))
   )
      )
      (setq e (entnext e))
      )
      ((= (atext 0) "SEQEND")
   (setq e nil))
      (T (setq e (entnext e)))
                       )
     )
 )
    )
           (if (= "MTEXT"            ; Look for MTEXT entity type (group 0)
              (cdr (assoc 0 (setq e (entget (ssname p l))))))
                 (progn
                    (setq chf nil si 1)
                    (setq s (cdr (setq as (assoc 1 e))))
                    (while (= osl (setq sl (strlen
                       (setq st (substr s si osl)))))
                       (if (= st os)
                          (progn
                             (setq s (strcat (substr s 1 (1- si)) ns
                                       (substr s (+ si osl))))
                          (setq chf t) ; Found old string
                       (setq si (+ si nsl))
                     )
                     (setq si (1+ si))
                 )
              )
              (if chf (progn        ; Substitute new string for old
                 (setq e (subst (cons 1 s) as e))
                 (entmod e)         ; Modify the TEXT entity
                 (setq chm (1+ chm))
              ))
           )
        )
    (if (= "DIMENSION"            ; Look for DIMENSION entity type (group 0)
              (cdr (assoc 0 (setq e (entget (ssname p l))))))
                 (progn
                    (setq chf nil si 1)
                    (setq s (cdr (setq as (assoc 1 e))))
                    (while (= osl (setq sl (strlen
                       (setq st (substr s si osl)))))
                       (if (= st os)
                          (progn
                             (setq s (strcat (substr s 1 (1- si)) ns
                                       (substr s (+ si osl))))
                          (setq chf t) ; Found old string
                       (setq si (+ si nsl))
                     )
                     (setq si (1+ si))
                 )
              )
              (if chf (progn        ; Substitute new string for old
                 (setq e (subst (cons 1 s) as e))
                 (entmod e)         ; Modify the TEXT entity
                 (setq chm (1+ chm))
              ))
           )
        )
    (if (= "TEXT"            ; Look for TEXT entity type (group 0)
              (cdr (assoc 0 (setq e (entget (ssname p l))))))
                 (progn
                    (setq chf nil si 1)
                    (setq s (cdr (setq as (assoc 1 e))))
                    (while (= osl (setq sl (strlen
                       (setq st (substr s si osl)))))
                       (if (= st os)
                          (progn
                             (setq s (strcat (substr s 1 (1- si)) ns
                                       (substr s (+ si osl))))
                          (setq chf t) ; Found old string
                       (setq si (+ si nsl))
                     )
                     (setq si (1+ si))
                 )
              )
              (if chf (progn        ; Substitute new string for old
                 (setq e (subst (cons 1 s) as e))
                 (entmod e)         ; Modify the TEXT entity
                 (setq chm (1+ chm))
              ))
           )
        )
    (setq l (1+ l))
)
)
    )
    (if (> chm 1)
       (princ (strcat "\nUpdated " (itoa chm) " text strings"))
       (princ (strcat "\nUpdated " (itoa chm) " text string"))
    )
    (terpri)
)
;
(defun atext (num)
  (cdr (assoc num d))
)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...