Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
erickson123
2411 Views, 5 Replies

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

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....

5 REPLIES 5
Message 2 of 6
hmsilva
in reply to: erickson123

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

Message 3 of 6
erickson123
in reply to: hmsilva

RIGHT ON!

 

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

 

Thanks.

Message 4 of 6
hmsilva
in reply to: erickson123

You're welcome, erickson123
Glad I could help

Henrique

EESignature

Message 5 of 6
amro013
in reply to: hmsilva

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

thanks

Message 6 of 6
erickson123
in reply to: amro013

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

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost