Author Topic: Text modifcation lisp  (Read 4951 times)

0 Members and 1 Guest are viewing this topic.

Artisan

  • Guest
Text modifcation lisp
« 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

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Text modifcation lisp
« Reply #1 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
TheSwamp.org  (serving the CAD community since 2003)

hudster

  • Gator
  • Posts: 2848
Text modifcation lisp
« Reply #2 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;
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Text modifcation lisp
« Reply #3 on: September 08, 2004, 10:31:47 AM »
I like that even better. :D
TheSwamp.org  (serving the CAD community since 2003)

M-dub

  • Guest
Text modifcation lisp
« Reply #4 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.