Jump to content

Recommended Posts

Posted

I got this Text Align LISP a little while back and I am having some issues with it. I will align text based on the Y or Y position you choose. It works fine if all the text is left justified, but if the text is not all left justified it seems to get a bit messy. Can someone take a look at it and see if you can see where there might be a mistake?

 

 

 

;TEXTALIGN.lsp modified 04/07/97 Jeff Foster
;
;OBJECTIVE***
;The purpose of this routine is to allow the user to align
;multiple text objects based on either an x or y ordinate.
;The text is aligned based upon it's justification
;
;TO RUN***
;At the command line, type (load "c:/lispdir/textalign")
;where c:/ is the drive where TEXTALIGN.lsp is contained
;where lispdir/ is the directory where TEXTALIGN.lsp is contained
;
;
;If you find this routine to be helpful, please give consideration
;to making a cash contribution of $10.00 to:
;         Jeff Foster
;         590 Penny Rd.
;         Angier, NC 27501
;

(DEFUN C:TAH ()
 (INITGET 1 "X x Y y")
 (SETQ XY_ORD (GETKWORD "\nALIGN <X> OR <Y> ORDINATE OF TEXT?: "))
 (SETQ ORD (GETPOINT "\nPICK ORDINATE: "))
 (PRINC "\nSELECT TEXT TO ALIGN")
 (SETQ SS (SSGET))
 (WHILE (> (SSLENGTH SS) 0)
   (SETQ EN (SSNAME SS 0))
   (SETQ ED (ENTGET EN))
   (SETQ AS (CDR (ASSOC '0 ED)))
   (if (= AS "TEXT")
     (progn
       (setq code72 (cdr (assoc 72 ed)))
       (setq code73 (cdr (assoc 73 ed)))
     )
   )
   (cond ((and (= AS "TEXT") (= code72 0) (= code73 0))
       (setq pt1 (cdr (assoc '10 ed)))
       (setq pt1_x (car pt1))
       (setq pt1_y (cadr pt1))
         )
         ((and (= AS "TEXT") (/= code72 0) (/= code73 0))
       (setq pt1 (cdr (assoc '11 ed)))
       (setq pt1_x (car pt1))
       (setq pt1_y (cadr pt1))
         )
         ((and (= AS "TEXT") (= code72 0) (/= code73 0))
       (setq pt1 (cdr (assoc '11 ed)))
       (setq pt1_x (car pt1))
       (setq pt1_y (cadr pt1))
         )
         ((and (= AS "TEXT") (/= code72 0) (= code73 0))
       (setq pt1 (cdr (assoc '11 ed)))
       (setq pt1_x (car pt1))
       (setq pt1_y (cadr pt1))
         )
   )
   (COND ((and (= AS "TEXT") (= XY_ORD "X"))
     (COMMAND "MOVE" EN "" PT1 (LIST (CAR ORD) PT1_Y))
     (SSDEL EN SS)
         )
         ((AND (= AS "TEXT") (= XY_ORD "Y"))
     (COMMAND "MOVE" EN "" PT1 (LIST PT1_X (CADR ORD)))
     (SSDEL EN SS)
         )
         ((/= AS "TEXT")
     (SSDEL EN SS)
         )
   )
 )
 (PRIN1)
)

  • Replies 28
  • Created
  • Last Reply

Top Posters In This Topic

  • AQucsaiJr

    15

  • CAB

    4

  • alanjt

    3

  • Lee Mac

    3

Top Posters In This Topic

Posted

Does anyone know where I can find another LISP that can do this?

Posted

Maybe something like this:

 

[b][color=BLACK]([/color][/b]defun c:jtext [b][color=FUCHSIA]([/color][/b]/ ss i en ed g72 g73 just[b][color=FUCHSIA])[/color][/b]

[b][color=FUCHSIA]([/color][/b]initget 1 [color=#2f4f4f]"Left Center Right TL TC TR ML MIddle MR BL BC BR"[/color][b][color=FUCHSIA])[/color][/b]
[b][color=FUCHSIA]([/color][/b]setq just [b][color=NAVY]([/color][/b]getkword [color=#2f4f4f]"\nText Justification - Left/Center/Right/TL/TC/TR/ML/MIddle/MR/BL/BC/BR:   "[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]


[b][color=FUCHSIA]([/color][/b]cond [b][color=NAVY]([/color][/b][b][color=MAROON]([/color][/b]= just [color=#2f4f4f]"Left"[/color][b][color=MAROON])[/color][/b]   [b][color=MAROON]([/color][/b]setq g72 0 g73 0[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
     [b][color=NAVY]([/color][/b][b][color=MAROON]([/color][/b]= just [color=#2f4f4f]"Center"[/color][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]setq g72 1 g73 0[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
     [b][color=NAVY]([/color][/b][b][color=MAROON]([/color][/b]= just [color=#2f4f4f]"Right"[/color][b][color=MAROON])[/color][/b]  [b][color=MAROON]([/color][/b]setq g72 2 g73 0[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
     [b][color=NAVY]([/color][/b][b][color=MAROON]([/color][/b]= just [color=#2f4f4f]"MIddle"[/color][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]setq g72 4 g73 0[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
     [b][color=NAVY]([/color][/b][b][color=MAROON]([/color][/b]= just [color=#2f4f4f]"TL"[/color][b][color=MAROON])[/color][/b]     [b][color=MAROON]([/color][/b]setq g72 0 g73 3[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
     [b][color=NAVY]([/color][/b][b][color=MAROON]([/color][/b]= just [color=#2f4f4f]"TC"[/color][b][color=MAROON])[/color][/b]     [b][color=MAROON]([/color][/b]setq g72 1 g73 3[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
     [b][color=NAVY]([/color][/b][b][color=MAROON]([/color][/b]= just [color=#2f4f4f]"TR"[/color][b][color=MAROON])[/color][/b]     [b][color=MAROON]([/color][/b]setq g72 2 g73 3[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
     [b][color=NAVY]([/color][/b][b][color=MAROON]([/color][/b]= just [color=#2f4f4f]"ML"[/color][b][color=MAROON])[/color][/b]     [b][color=MAROON]([/color][/b]setq g72 0 g73 2[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
     [b][color=NAVY]([/color][/b][b][color=MAROON]([/color][/b]= just [color=#2f4f4f]"MR"[/color][b][color=MAROON])[/color][/b]     [b][color=MAROON]([/color][/b]setq g72 2 g73 2[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
     [b][color=NAVY]([/color][/b][b][color=MAROON]([/color][/b]= just [color=#2f4f4f]"BL"[/color][b][color=MAROON])[/color][/b]     [b][color=MAROON]([/color][/b]setq g72 0 g73 1[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
     [b][color=NAVY]([/color][/b][b][color=MAROON]([/color][/b]= just [color=#2f4f4f]"BC"[/color][b][color=MAROON])[/color][/b]     [b][color=MAROON]([/color][/b]setq g72 1 g73 1[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
     [b][color=NAVY]([/color][/b][b][color=MAROON]([/color][/b]= just [color=#2f4f4f]"BR"[/color][b][color=MAROON])[/color][/b]     [b][color=MAROON]([/color][/b]setq g72 2 g73 1[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

[b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]not ss[b][color=NAVY])[/color][/b]
      [b][color=NAVY]([/color][/b]princ [color=#2f4f4f]"\nSelect TEXT Entities To Edit..."[/color][b][color=NAVY])[/color][/b]
      [b][color=NAVY]([/color][/b]setq ss [b][color=MAROON]([/color][/b]ssget [b][color=GREEN]([/color][/b]list [b][color=BLUE]([/color][/b]cons 0 [color=#2f4f4f]"TEXT"[/color][b][color=BLUE])[/color][/b]
                            [b][color=BLUE]([/color][/b]if [b][color=RED]([/color][/b]getvar [color=#2f4f4f]"CTAB"[/color][b][color=RED])[/color][/b]
                                [b][color=RED]([/color][/b]cons 410 [b][color=PURPLE]([/color][/b]getvar [color=#2f4f4f]"CTAB"[/color][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b]
                                [b][color=RED]([/color][/b]cons 67 [b][color=PURPLE]([/color][/b]- 1 [b][color=TEAL]([/color][/b]getvar [color=#2f4f4f]"TILEMODE"[/color][b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

[b][color=FUCHSIA]([/color][/b]setq i [b][color=NAVY]([/color][/b]sslength ss[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
[b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]not [b][color=MAROON]([/color][/b]minusp [b][color=GREEN]([/color][/b]setq i [b][color=BLUE]([/color][/b]1- i[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
      [b][color=NAVY]([/color][/b]setq en [b][color=MAROON]([/color][/b]ssname ss i[b][color=MAROON])[/color][/b]
            ed [b][color=MAROON]([/color][/b]entget en[b][color=MAROON])[/color][/b]
            ed [b][color=MAROON]([/color][/b]subst [b][color=GREEN]([/color][/b]cons 72 g72[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]assoc 72 ed[b][color=GREEN])[/color][/b] ed[b][color=MAROON])[/color][/b]
            ed [b][color=MAROON]([/color][/b]subst [b][color=GREEN]([/color][/b]cons 73 g73[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]assoc 73 ed[b][color=GREEN])[/color][/b] ed[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
       [b][color=NAVY]([/color][/b]entmod ed[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

[b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

-David

Posted

Alanjt;

I found this thread to be very helpful, thank you.

 

David;

This is not exactly what I was looking for but thank you, I can use this.

Posted
Alanjt;

I found this thread to be very helpful, thank you.

 

David;

This is not exactly what I was looking for but thank you, I can use this.

 

No sweat, found that long ago and have been enjoying it myself.

 

David, what's the difference in what you posted and JustifyText or did that not exist in older versions of acad?

Posted

[quote name=alanjt;272720

David' date=' what's the difference in what you posted and JustifyText or did that not exist in older versions of acad?

 

Never heard of it. Must be a later release. Maybe an Express Tool? -David

Posted
Never heard of it. Must be a later release. Maybe an Express Tool? -David

 

 

Nope, it's core. However, like I said, I don't know if it was around in v12. I was just curious, that's all.

Posted
I don't really like this one... It controls to much... Juat looking for a simple command to line up existing text.

 

Yeah. I didn't like it much at first either. A bit too intrusive, until I commented out some code. Here's the modified version that works for me. You might like this version a bit better.

 

SteveJ

 

 

;****************************************************************
;****************************************************************
;Posted by ASMI/14th Aug 2008
;http://www.cadtutor.net/forum/showpost.php?p=167350
;
;SINGLE LINE TEXT ALIGNMENT TOOL. 
;
;****************************************************************
; Then I went and changed it some.  SJ
;****************************************************************
(defun c:TEXTALIGN (/ tHeight insPoint dtSet oldDisMode errFlag 
                sStr tAlignPt tAlignment disDelta dtList 
                oldStrDis hitStr alignList oldMinPt maxPt
         minPt oldAlign oldDirect)

 (vl-load-com) 
 (defun texAlign (item /)
   (if(= TEXTALIGN:Direct "Y")
     (progn
         (setq disDelta(- disDelta TEXTALIGN:strDis)); end setq 
     (vla-put-Alignment (car str) tAlignment) 
     (cond 
  ((= tAlignment 0) 
     (vla-put-InsertionPoint (car str) 
       (vlax-3D-Point(car insPoint) 
         (+ disDelta(cadr insPoint))(nth 2 insPoint))) 
   ) 
  ((member tAlignment '(1 2 4 6 7 8 9 10 11 12 13 14)) 
     (vla-put-TextAlignmentPoint (car str) 
       (vlax-3D-Point(car tAlignPt) 
         (+ disDelta(cadr tAlignPt))(nth 2 tAlignPt))) 
   ) 
  ((member tAlignment '(3 5)) 
   (princ "\nCan't align string with Aligned or Fit alignment ") 
   ) 
  ); end cond
); end progn
     (progn
     (setq disDelta(- disDelta TEXTALIGN:strDis)); end setq 
     (vla-put-Alignment (car str) tAlignment) 
     (cond 
  ((= tAlignment 0) 
     (vla-put-InsertionPoint (car str) 
       (vlax-3D-Point(-(car insPoint)disDelta)
         (cadr insPoint)(nth 2 insPoint))) 
   ) 
  ((member tAlignment '(1 2 4 6 7 8 9 10 11 12 13 14)) 
     (vla-put-TextAlignmentPoint (car str) 
       (vlax-3D-Point(-(car tAlignPt)disDelta)
         (cadr tAlignPt)(nth 2 tAlignPt))) 
   ) 
  ((member tAlignment '(3 5)) 
   (princ "\nCan't align string with Aligned or Fit alignment ") 
   ) 
  ); end cond
     ); end progn
   ); end if
   ); end of texAlign
 (if(not TEXTALIGN:Direct)(setq TEXTALIGN:Direct "Y"))
 (setq oldDirect TEXTALIGN:Direct)
 (if(not TEXTALIGN:Align)(setq TEXTALIGN:Align "H"))
 (setq oldAlign TEXTALIGN:Align)
 (if(not TEXTALIGN:disMode)(setq TEXTALIGN:disMode "S")) 
 (setq oldDisMode TEXTALIGN:disMode) 
 (if(not TEXTALIGN:strDis)(setq TEXTALIGN:strDis 4.1666667)) ;;; ORIGINALLY 4.167
 (setq oldStrDis TEXTALIGN:strDis)

[color=red][i];;REMOVES X-axis/Y-axis direction question [/i][/color]
[color=red][i];;  (initget "Y X")[/i][/color]
[color=red][i];;  (setq TEXTALIGN:Direct [/i][/color]
[color=red][i];;    (getkword [/i][/color]
[color=red][i];;      (strcat "\nSpecify alignment direction [X-axis/Y-axis] <"TEXTALIGN:Direct">: ")))[/i][/color]

 (if(null TEXTALIGN:Direct)(setq TEXTALIGN:Direct oldDirect))

[color=red][b];;REMOVES justification question[/b][/color]
[color=red][b];;  (initget "H L C M R TL TC TR ML MC MR BL BC BR")[/b][/color]
[color=red][b];;  (setq TEXTALIGN:Align [/b][/color]
[color=red][b];;    (getkword [/b][/color]
[color=red][b];;      (strcat "\nSpecify justification [Hitest string/Left/Center/Middle/Right/TL/TC/TR/ML/MC/MR/BL/BC/BR] <"TEXTALIGN:Align">: "))[/b][/color]
[color=red][b];;  alignList '(("L" 0)("C" 1)("R" 2)("M" 4)("TL" 6)("TC" 7)("TR" ("ML" 9)("MC" 10)("MR" 11)("BL" 12)("BC" 13)("BR" 14))[/b][/color]
[color=red][b];;       ); end setq [/b][/color]

 (if(null TEXTALIGN:Align)(setq TEXTALIGN:Align oldAlign))

[color=red][i];;REMOVES distance between strings question[/i][/color]
[color=red][i];;  (initget "S C")[/i][/color]
[color=red][i];;  (setq TEXTALIGN:disMode [/i][/color]
[color=red][i];;    (getkword [/i][/color]
[color=red][i];;      (strcat "\nSpecify distance between strings [standard/Custom][/i][/color]

"TEXTALIGN:disMode">: "))) 
 (if(null TEXTALIGN:disMode)(setq TEXTALIGN:disMode oldDisMode)) 
 (if(= TEXTALIGN:disMode "C") 
   (progn 
   (setq TEXTALIGN:strDis(getdist(strcat "\nSpecify Custom distance <"(rtos TEXTALIGN:strDis)">: "))) 
   (if(null TEXTALIGN:strDis)(setq TEXTALIGN:strDis oldStrDis)) 
   (princ(strcat "\nCustom distance is "(rtos TEXTALIGN:strDis))) 
    ); end progn 
   ); end if
 (while T
 (princ "\n<<< Select DText and press Enter or Esc to Quit >>> ") 
  (if 
    (setq dtSet(ssget '((0 . "TEXT")))) 
   (progn
     (if(= "Y" TEXTALIGN:Direct)
     (setq dtList(vl-sort(mapcar 
          '(lambda (x)(list x 
        (+(cadr(vlax-safearray->list 
            (vlax-variant-value 
              (vla-get-InsertionPoint x)))) 
                (cadr(vlax-safearray->list 
            (vlax-variant-value 
              (vla-get-TextAlignmentPoint x))))))) 
      (mapcar 'vlax-ename->vla-object 
                 (vl-remove-if 'listp 
                    (mapcar 'cadr(ssnamex dtSet)))))
          (function(lambda(a b)(>(cadr a)(cadr b))))))
(setq dtList(vl-sort(mapcar 
          '(lambda (x)(list x 
        (+(car(vlax-safearray->list 
            (vlax-variant-value 
              (vla-get-InsertionPoint x)))) 
                (car(vlax-safearray->list 
            (vlax-variant-value 
              (vla-get-TextAlignmentPoint x))))))) 
      (mapcar 'vlax-ename->vla-object 
                 (vl-remove-if 'listp 
                    (mapcar 'cadr(ssnamex dtSet)))))
          (function(lambda(a b)(<(cadr a)(cadr b))))))
      ); end if

    (setq hitStr(caar dtList))

     (if(/= "H" TEXTALIGN:Align)
(progn
  (vla-getBoundingBox hitStr 'oldMinPt 'MaxPt)
  (foreach lst alignList
      (if(=(car lst)TEXTALIGN:Align)
        (progn
   (if 
                         (not 
                          (vl-catch-all-error-p 
                           (vl-catch-all-apply 'vla-put-Alignment(list hitStr(cadr lst)))))
    (progn
      (vla-getBoundingBox hitStr 'minPt 'maxPt)
      (vla-move hitStr minPt oldMinPt)
      ); end progn
    ); end if
   ); end progn
        ); end if
    ); end foreach
  ); end progn
); end if

    (setq tHeight(vla-get-Height hitStr) 
          insPoint(vlax-safearray->list 
                    (vlax-variant-value 
                      (vla-get-InsertionPoint hitStr))) 
          tAlignPt(vlax-safearray->list 
                    (vlax-variant-value 
                      (vla-get-TextAlignmentPoint hitStr))) 
          tAlignment(vla-get-Alignment hitStr) 
          dtList(cdr dtList) 
          disDelta 0.0 
    ); end setq 
   (if(= TEXTALIGN:disMode "S")(setq TEXTALIGN:strDis(* 1.6666668 tHeight))) ;;; ORIGINALLY 1.6668 
     (foreach str dtList 
    (if 
  (not 
      (vl-catch-all-error-p 
           (vl-catch-all-apply 'texAlign (list str)))) 
      (princ) 
      (setq errFlag T) 
      ); end if 
  ); end foreach 
     (if errFlag(princ "\n<!> Some Entities on Locked Layer <!>")) 
 ); end progn 
   (princ "\nStrings isn't selected. ") 
   ); end if
   ); end while
   (princ) 
   ); end of dali
(princ "\nType TEXTALIGN to Run ")

Posted

Found this in my archive, think I wrote it a while back.... :geek:

 

Should work with TEXT/MTEXT:

 

(defun c:talign  (/ ss pt tmp elst)
 (vl-load-com)
 (or tal:def (setq tal:def "Left"))
 (if (and (setq ss (ssget '((0 . "*TEXT"))))
          (setq pt (getpoint "\nSelect Alignment Point: ")))
   (progn
     (setq pt (trans pt 1 0))
     (initget "Left Middle Right")
     (setq tmp (getkword (strcat "\nAlignment? [L/M/R] <" tal:def ">: ")))
     (or (not tmp) (setq tal:def tmp))
     (foreach elst  (mapcar 'entget
                      (vl-remove-if 'listp
                        (mapcar 'cadr (ssnamex ss))))
       (cond ((eq "TEXT" (cdr (assoc 0 elst)))
              (setq elst (mod 10 (list (car pt)
                                       (caddr (assoc 10 elst))
                                       (cadddr (assoc 10 elst))) elst))
              (mod 72 (cond ((eq tal:def "Left") 0)
                            ((eq tal:def "Middle") 1)
                            ((eq tal:def "Right") 2))
                   (mod 11 (cdr (assoc 10 elst)) elst)))
             ((eq "MTEXT" (cdr (assoc 0 elst)))
              (setq elst (mod 10 (list (car pt)
                                       (caddr (assoc 10 elst))
                                       (cadddr (assoc 10 elst))) elst))
              (mod 71 (cond ((eq tal:def "Left") 1)
                            ((eq tal:def "Middle") 2)
                            ((eq tal:def "Right") 3)) elst)))))
   (princ "\n<!> No Text Selected <!>"))
 (princ))

(defun mod (code val elst)
 (entmod
   (subst
     (cons code val)
       (assoc code elst) elst)))

Posted

I like this code:

 

However I don't know whats going on within it that is causing my Undo to be turned off? What causes this to happen?

Here is the code:

(defun c:AO (/ ActDoc Sel AliObj AliLl AliUr ss AliOpt Ent tempObj tempLl tempUr)

   (vl-load-com)
   (setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
   (vla-EndUndoMark ActDoc)
   (vla-StartUndoMark ActDoc)
   (if
       (and
           (setq Sel (entsel "\n Select base object (for aligning): "))
           (not (redraw (car Sel) 3))
           (setq AliObj (vlax-ename->vla-object (car Sel)))
           (not (vla-GetBoundingBox AliObj 'AliLl 'AliUr))
           (setq AliLl (safearray-value AliLl))
           (setq AliUr (safearray-value AliUr))
           (setq ss (ssget))
           (not (initget "Left Right Center Top Bottom"))
           (setq AliOpt
               (if (setq AliOpt (getkword "\n Alignment option [Center / Left / Right / Top / Bottom]: <Center> "))
                   AliOpt
                   "Center"
               )
           )
           (setq cnt -1)
       )
       (while (setq Ent (ssname ss (setq cnt (1+ cnt))))
           (setq tempObj (vlax-ename->vla-object Ent))
           (vla-GetBoundingBox tempObj 'tempLl 'tempUr)
           (setq tempLl (safearray-value tempLl))
           (setq tempUr (safearray-value tempUr))
           (cond
               ((= AliOpt "Center")
                   (vlax-invoke
                       tempObj
                       'Move
                       (mapcar '(lambda (a b) (/ (+ a b) 2.0)) tempLl tempUr)
                       (mapcar '(lambda (a b) (/ (+ a b) 2.0)) AliLl AliUr)
                   )
               )
               ((= AliOpt "Left")
                   (vlax-invoke
                       tempObj
                       'Move
                       tempLl
                       (list
                           (car AliLl)
                           (cadr tempLl)
                           (caddr tempLl)
                       )
                   )
               )
               ((= AliOpt "Right")
                   (vlax-invoke
                       tempObj
                       'Move
                       tempUr
                       (list
                           (car AliUr)
                           (cadr tempUr)
                           (caddr tempUr)
                       )
                   )
               )
               ((= AliOpt "Top")
                   (vlax-invoke
                       tempObj
                       'Move
                       tempUr
                       (list
                           (car tempUr)
                           (cadr AliUr)
                           (caddr tempUr)
                       )
                   )
               )
               ((= AliOpt "Bottom")
                   (vlax-invoke
                       tempObj
                       'Move
                       tempLl
                       (list
                           (car tempLl)
                           (cadr AliLl)
                           (caddr tempLl)
                       )
                   )
               )
           )
       )
   )
   (if Sel (redraw (car Sel) 4))
   (vla-EndUndoMark ActDoc)
   (princ)
)
(prompt "\nEnter AO to start.")

 

PS... Thanks Lee I like that one too!:D

Posted

Is that the only thing thats causing this?... It was aggravating me. I thought I was doing something wrong.

Posted
Is that the only thing thats causing this?... It was aggravating me. I thought I was doing something wrong.

 

I haven't had a proper look, but that looks like it may be causing the problems you are describing.

Posted

I will give it a try... Thanks again Lee

Posted

Ever since I loaded that text alignment LISP, every drawing I open, the Undo command is disabled... I am missing something.

This is the code in question:

(defun c:TAH (/ ActDoc Sel AliObj AliLl AliUr ss AliOpt Ent tempObj tempLl tempUr)

   (vl-load-com)
   (setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
   (vla-StartUndoMark ActDoc)
   (if
       (and
           (setq Sel (entsel "\n Select base object (for aligning): "))
           (not (redraw (car Sel) 3))
           (setq AliObj (vlax-ename->vla-object (car Sel)))
           (not (vla-GetBoundingBox AliObj 'AliLl 'AliUr))
           (setq AliLl (safearray-value AliLl))
           (setq AliUr (safearray-value AliUr))
           (setq ss (ssget))
           (not (initget "Left Right Center Top Bottom"))
           (setq AliOpt
               (if (setq AliOpt (getkword "\n Alignment option [Center / Left / Right / Top / Bottom]: <Center> "))
                   AliOpt
                   "Center"
               )
           )
           (setq cnt -1)
       )
       (while (setq Ent (ssname ss (setq cnt (1+ cnt))))
           (setq tempObj (vlax-ename->vla-object Ent))
           (vla-GetBoundingBox tempObj 'tempLl 'tempUr)
           (setq tempLl (safearray-value tempLl))
           (setq tempUr (safearray-value tempUr))
           (cond
               ((= AliOpt "Center")
                   (vlax-invoke
                       tempObj
                       'Move
                       (mapcar '(lambda (a b) (/ (+ a b) 2.0)) tempLl tempUr)
                       (mapcar '(lambda (a b) (/ (+ a b) 2.0)) AliLl AliUr)
                   )
               )
               ((= AliOpt "Left")
                   (vlax-invoke
                       tempObj
                       'Move
                       tempLl
                       (list
                           (car AliLl)
                           (cadr tempLl)
                           (caddr tempLl)
                       )
                   )
               )
               ((= AliOpt "Right")
                   (vlax-invoke
                       tempObj
                       'Move
                       tempUr
                       (list
                           (car AliUr)
                           (cadr tempUr)
                           (caddr tempUr)
                       )
                   )
               )
               ((= AliOpt "Top")
                   (vlax-invoke
                       tempObj
                       'Move
                       tempUr
                       (list
                           (car tempUr)
                           (cadr AliUr)
                           (caddr tempUr)
                       )
                   )
               )
               ((= AliOpt "Bottom")
                   (vlax-invoke
                       tempObj
                       'Move
                       tempLl
                       (list
                           (car tempLl)
                           (cadr AliLl)
                           (caddr tempLl)
                       )
                   )
               )
           )
       )
   )
   (if Sel (redraw (car Sel) 4))
   (vla-EndUndoMark ActDoc)
   (princ)
)
(prompt "\nEnter TAH to start.")

 

*I unloaded this LISP and the problem, disabling the undo command, still exists. I have posted this issue on the General AutoCAD Questions section of the forum.

  • 2 weeks later...
Posted

 

 

I have been using this LISP for a little while now and have found a problem, only concerning what I use it for, otherwise it works fine.

I need to be able to align text in both the X-Axis direction and Y-Axis direction and this only seems to be able to align text in the Y-Axis. So when I have text stacked on top of each other, there is no alignment choice I can use that will not place them all on top of each other. Anyone know how I can either fix this or just know of another LISP I can try?

I really like how this one can align the text without changing the insertion, and it seems most of the text alignment LISP I find all change the insertion.

Posted

Another version:

http://www.theswamp.org/index.php?topic=25824.msg362167#msg362167

 

;; Align a group of text or mtext objects along there X or Y axis

;; User picks Master text & then text to align under it

;; Does not change the text alignment or justification or combine text

;; Uses the justification of the Master text to set alignment

;; This routine simply moves & rotates the text

;; Will allow Master text on any angle

;;

;; ----- N O T E S ------

;; only supports vertical alignment at this time, will add Horizontal

;; you must select text in order top to bottom, need to allow sorting

;; on the x or y axis, see note on line 47

;; No support for UCS at this time

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...