Lisp to change Oblique Angle in Text and Mtext in BLOCK?

Lisp to change Oblique Angle in Text and Mtext in BLOCK?

erickson123
Advocate Advocate
3,056 Views
5 Replies
Message 1 of 6

Lisp to change Oblique Angle in Text and Mtext in BLOCK?

erickson123
Advocate
Advocate

Hi Everyone,

 

Does anyone have a lisp to change the oblique angle (to 30 or whatever) inside a block that contains Text AND Mtext.  I've been coming up dry on my searches.  Thanks in advance!!

 

I've attached a block I would like to use it on....

0 Likes
Accepted solutions (1)
3,057 Views
5 Replies
Replies (5)
Message 2 of 6

hmsilva
Mentor
Mentor
Accepted solution

Hi erickson123,

 

mtext is formated in the text string, not a propertie from the object.

Just a starting point.

(vl-load-com)
(defun c:demo (/ attlst hnd i lst obj str ss)
  (if (setq ss (ssget '((0 . "INSERT") (66 . 1))))
    (progn
      (repeat (setq i (sslength ss))
        (setq hnd    (ssname ss (setq i (1- i)))
              attlst nil
              obj    (vlax-ename->vla-object hnd)
              attlst (vlax-invoke obj 'GetAttributes)
        )
        (foreach att attlst
          (if (= (vla-get-MTextAttributeContent att) "")
            (vla-put-ObliqueAngle att (* pi (/ 30.0 180.0)))
            (vla-put-TextString att (strcat "\\Q30.0;" (vla-get-TextString att)))
          )
        )
      )
    )
  )
  (princ)
)

 

Henrique

 

EESignature

0 Likes
Message 3 of 6

erickson123
Advocate
Advocate

RIGHT ON!

 

You are definitely TOP OF THE FOOD CHAIN!!!!

 

Thanks.

0 Likes
Message 4 of 6

hmsilva
Mentor
Mentor
You're welcome, erickson123
Glad I could help

Henrique

EESignature

0 Likes
Message 5 of 6

Anonymous
Not applicable

How it works , I try to use it but no result

thanks

0 Likes
Message 6 of 6

erickson123
Advocate
Advocate

I'm not a lisp writer, but this is how the lisp in the other message changed for our needs.  We use it to change text in topo maps from 'straight' to a 30deg slant.

 

 

(defun C:TX30 (/ ans text_entities mtext_entities)
  (vl-load-com)
 

;---------------------------------- TEXT & MTXEXT ---------------------------------------------
  (command "STYLE" "SIMPLEX S" "SIMPLEX" (* 0.00 (GETVAR "DIMSCALE")) "1.0" "30" "No" "No" "No")
  (setq text_entities
    (ssget "X"
      '((0 . "TEXT")(410 . "Model")
         (-4 . "<NOT")
           (-4 . "<OR")
             (8 . "*NA-SCALE*")(8 . "*STREET*")
           (-4 . "OR>")
         (-4 . "NOT>")
       )
    )
  )
  (setq mtext_entities
    (ssget "X"
      '((0 . "MTEXT")(410 . "Model")
         (-4 . "<NOT")
           (-4 . "<OR")
             (8 . "*NA-SCALE*")(8 . "*STREET*")
           (-4 . "OR>")
         (-4 . "NOT>")
       )
    )
  )
  (if text_entities
     (command "Optchprop" text_entities "" "t" "SIMPLEX S" "")
  );endif
  (if mtext_entities
    (command "Optchprop" mtext_entities "" "t" "SIMPLEX S" "")
  );endif
   

;--------------------------------- BLOCK ATTRIBUTES --------------------------------------------

(if (setq ss (ssget "X" '((0 . "INSERT") (66 . 1)(410 . "Model"))))
  (progn
    (repeat (setq i (sslength ss))
    (setq hnd (ssname ss (setq i (1- i)))
   attlst nil
   obj (vlax-ename->vla-object hnd)
   attlst (vlax-invoke obj 'GetAttributes)
  
    )
    (foreach att attlst
      (if (= (vla-get-MTextAttributeContent att) "")
 (vla-put-ObliqueAngle att (* pi (/ 30.0 180.0)))
 (vla-put-TextString att (strcat "\\Q30.0;" (vla-get-TextString att)))
 )
    )
    )
   )
  )
 (princ)
);defun

 

0 Likes