TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Artisan on September 08, 2004, 08:24:09 AM

Title: Text modifcation lisp
Post by: Artisan on September 08, 2004, 08:24:09 AM
I was hoping to find a text lisp that allows me to select a text string and change the justification from it's current setting to center. I am always having to bring up the properties box to do this and I have always wondered about a lisp that would do it for me.


**edit: This thread has been moved due to the fact that the Show your stuff forum is for offering up code, and the intent of this thread is clearly a call for help. -DCR
Title: Text modifcation lisp
Post by: Mark on September 08, 2004, 10:19:07 AM
You could use something like this.
Code: [Select]

(defun chg_align_pt (obj align / int_pt)
  (setq int_pt (vlax-get-property obj 'InsertionPoint))
  (vlax-put-property obj 'Alignment align)
  (vlax-put-property obj 'TextAlignmentPoint int_pt)
  )

;;; changed selected DTEXT to middle alignment
(defun c:cdt2mid (/ ent obj)
  (cond ((setq ent (car (entsel "\nSelect DTEXT to modify: ")))
         (setq obj (vlax-ename->vla-object ent))
         (if (vlax-property-available-p obj 'Alignment T)
           (progn
             (chg_align_pt obj acAlignmentMiddle);[1]
             (vlax-release-object obj)
             )
           (alert "Un-able to change that text")
           )
         )
        )
  )


;;; [1] alignment options
;;; acAlignmentCenter
;;; acAlignmentRight
;;; acAlignmentMiddle
;;; acAlignmentTopLeft
;;; acAlignmentTopCenter
;;; acAlignmentTopRight
;;; acAlignmentMiddleLeft
;;; acAlignmentMiddleCenter
;;; acAlignmentMiddleRight
;;; acAlignmentBottomLeft
;;; acAlignmentBottomCenter
;;; acAlignmentBottomRight
Title: Text modifcation lisp
Post by: hudster on September 08, 2004, 10:27:38 AM
Here are macros that I use, just assign them to a button and off you go.

Code: [Select]
Middle Centre Justify
^C^C_justifytext;\;mc;


Code: [Select]
Middle Left Justify
^C^C_justifytext;\;ml;


Code: [Select]
Middle Right Justify
^C^C_justifytext;\;mr;
Title: Text modifcation lisp
Post by: Mark on September 08, 2004, 10:31:47 AM
I like that even better. :D
Title: Text modifcation lisp
Post by: M-dub on September 08, 2004, 11:48:19 AM
Quote from: Hudster
Here are macros that I use, just assign them to a button and off you go.

Code: [Select]
Middle Centre Justify
^C^C_justifytext;\;mc;


Code: [Select]
Middle Left Justify
^C^C_justifytext;\;ml;


Code: [Select]
Middle Right Justify
^C^C_justifytext;\;mr;


That's what I use.  I used to use the CHT lisp, but that was before we had the justifytext command.  I still like to use the cht routine if I WANT to move the text, but the other has pretty well taken over.