Edit lisp so it can be used on MTEXT

Edit lisp so it can be used on MTEXT

Anonymous
Not applicable
600 Views
6 Replies
Message 1 of 7

Edit lisp so it can be used on MTEXT

Anonymous
Not applicable

Hi There,

Can anyone help with this lisp so it can also be used on MTEXT?

Many thanks if you can help.

Cheers

Al

(PROMPT "\nLOADING FILE .........")
;
;  CHANGE THE ROTATION OF SELECTED TEXT
;
(defun C:TT ( / selset newscl l n e as)
   (setq olderr *error* *error* err)
   (command "undo" "begin")   
   (GETSYS)
;;LCA - COMMENT: The UCS command has new options.
   (COMMAND "UCS" "W")
   (setq selset (ssget)
      newrot (getorient "\nNew Orientation,Pick 2 points (Return to leave same): ")
      newscl (getreal   "\nNew Height   (Return to leave same): ")
   )
   (if selset
      (progn
         (setq l 0 n (sslength selset))
         (while (< l n)
            (if (= "TEXT" (cdr (assoc 0 (setq e (entget (ssname selset l))))))
               (progn
                  (prompt ".")
                  (if newscl
                     (progn
                        (setq s (cdr (setq as (assoc 40 e))))
                        (setq e (subst (cons 40 newscl) as e))
                        (entmod e)
                     )
                  )
                  (if newrot  
                     (progn
                        (setq s (cdr (setq as (assoc 50 e)))
                           ;             cur (getvar "UCSNAME")
                           ;             n (cdr (assoc 12 (tblsearch "UCS" cur)))
                           ;             m (cdr (assoc 10 (tblsearch "UCS" cur)))
                           ;             ax (- (cadr n) (cadr m) ) bx (- (car n) (car m) )
                           ;             alpha (atan ax bx)
                        )
                        (setq e (subst (cons 50 newrot) as e))
                        (entmod e)
                     )
                  )  
               )
            )  
            (setq l (1+ l))
         )
      )
   )
;;LCA - COMMENT: The UCS command has new options.
   (command "ucs" "p")
   (command "osnap" "none")
   (command "move" "P" "" pause pause)
   (resetsys)
   (command "undo" "end")
   (princ)
)    
0 Likes
601 Views
6 Replies
Replies (6)
Message 2 of 7

paullimapa
Mentor
Mentor

Have you tried using the Express Tool command: TORIENT

 

 

Area Object Link | Attribute Modifier | Dwg Setup | Feet-Inch Calculator
Layer Apps | List on Steroids | VP Zoom Scales | Exchange App Store


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 7

Anonymous
Not applicable

Hi There,

Thanks for your reply.

For drafting purposes to get this to work in this Lisp is much more efficient for us.

Thanks

Allan

 

0 Likes
Message 4 of 7

ВeekeeCZ
Consultant
Consultant

@Anonymous wrote:

Hi There,

Can anyone help with this lisp so it can also be used on MTEXT?

Many thanks if you can help.

Cheers

Al

 


This could be very simple... just change of one line..

 

Spoiler
(PROMPT "\nLOADING FILE .........")
;
;  CHANGE THE ROTATION OF SELECTED TEXT

(defun C:TT ( / selset newscl l n e as)
  (setq olderr *error* *error* err)

  (setq selset (ssget))

  (command "undo" "begin")   
   (GETSYS)
;;LCA - COMMENT: The UCS command has new options.
   (COMMAND "UCS" "W")
   
   (setq 
      newrot (getorient "\nNew Orientation, Pick 2 points (Return to leave same): ")
      newscl (getreal   "\nNew Height   (Return to leave same): ")
   )
   (if selset
      (progn
         (setq l 0 n (sslength selset))
         (while (< l n)
            (if (wcmatch "*TEXT" (cdr (assoc 0 (setq e (entget (ssname selset l))))))
               (progn
                  (prompt ".")
                  (if newscl
                     (progn
                        (setq s (cdr (setq as (assoc 40 e))))
                        (setq e (subst (cons 40 newscl) as e))
                        (entmod e)
                     )
                  )
                  (if newrot  
                     (progn
                        (setq s (cdr (setq as (assoc 50 e)))
                           ;             cur (getvar "UCSNAME")
                           ;             n (cdr (assoc 12 (tblsearch "UCS" cur)))
                           ;             m (cdr (assoc 10 (tblsearch "UCS" cur)))
                           ;             ax (- (cadr n) (cadr m) ) bx (- (car n) (car m) )
                           ;             alpha (atan ax bx)
                        )
                        (setq e (subst (cons 50 newrot) as e))
                        (entmod e)
                     )
                  )  
               )
            )  
            (setq l (1+ l))
         )
      )
   )
;;LCA - COMMENT: The UCS command has new options.
   (command "ucs" "p")
   (command "osnap" "none")
   (command "move" "P" "" pause pause)
   (resetsys)
   (command "undo" "end")
   (princ)
)

 

Also I do recommend to separate ssget function and move it in front of first command function. This allows you preselection.

 

0 Likes
Message 5 of 7

allanthebruce
Advocate
Advocate

Thanks for your reply, Did you test this, I still cant get it to rotate to the direction I am wanting? It seems to ignore my rotation I am specifying??

Any ideas is much appreciated.

Thanks

Allan

0 Likes
Message 6 of 7

ВeekeeCZ
Consultant
Consultant

I did... but something else. wcmatch must be otherwise... Sorry about it.

 

(if (wcmatch (cdr (assoc 0 (setq e (entget (ssname selset l))))) "*TEXT")
Message 7 of 7

allanthebruce
Advocate
Advocate

Legend! Thanks so much!!

Cheers

Al

0 Likes