Jump to content

Recommended Posts

Posted

Hi All,

 

I was wondering if someone could help out editing lee-macs align text lisp so that when the text aligns it doesnt change the position of the text in the 'y' direction. at the moment when I run this it moves all the text in x direction to align which is great but it also moves the text in y direction so they're all equally spaced. if anyone could let me know how to prevent the text from moving in y direction that would be great

 

would like it to end up looking like the last image below, instead of the 2nd. i've also attached a copy of the lisp file

 

(or if anyone could point me to a different lisp file that can do what I described, that would also be great!)

 

edit - forgot to say thanks to lee mac for creating this in the first place too! lee mac lisps are brilliant. good work

eg1.JPG

eg2.JPG

eg3.JPG

AlignTextV1-3.lsp

Posted

because unless i'm missing something, that doesn't actually align the text does it?

Posted

Please try the following:

;;--------------------=={ Align Text }==----------------------;;
;;                                                            ;;
;;  This program enables the user to reposition a selection   ;;
;;  of text objects equispaced by a factor of the text height ;;
;;  and aligned in a direction perpendicular to the rotation  ;;
;;  angle of the text.                                        ;;
;;                                                            ;;
;;  The program assumes all text objects in the selection     ;;
;;  have the same rotation and will align each text object    ;;
;;  using its Text Alignment Point.                           ;;
;;                                                            ;;
;;  The program will perform successfully with text           ;;
;;  constructed in any UCS plane.                             ;;
;;------------------------------------------------------------;;
;;  Author: Lee Mac, Copyright © 2013 - www.lee-mac.com       ;;
;;------------------------------------------------------------;;
;;  Version 1.3    -    23-04-2013                            ;;
;;------------------------------------------------------------;;
;;  Modified to retain vertical spacing - LM 2016-01-15       ;;
;;------------------------------------------------------------;;

(defun c:at ( / *error* ang bpt enx inc ins lst ocs sel vc1 vc2 )

   (defun *error* ( msg )
       (LM:endundo (LM:acdoc))
       (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))
           (princ (strcat "\nError: " msg))
       )
       (princ)
   )

   (if (setq sel (ssget "_:L" '((0 . "TEXT"))))
       (progn
           (setq inc (sslength sel)
                 enx (entget (ssname sel (1- inc)))
                 ang (cdr (assoc 50 enx))
                 ocs (trans '(0.0 0.0 1.0) 1 0 t)
                 vc1 (trans (list    (cos ang)  (sin ang)) ocs 0)
                 vc2 (trans (list (- (sin ang)) (cos ang)) ocs 0)
           )
           (repeat inc
               (setq enx (entget (ssname sel (setq inc (1- inc))))
                     lst (cons (list  (trans (aligntext:gettextinsertion enx) (cdr (assoc -1 enx)) 0) enx) lst)
                     ins (cons (caddr (trans (caar lst) 0 vc2)) ins)
               )
           )
           (setq lst (mapcar '(lambda ( n ) (nth n lst)) (vl-sort-i ins '>))
                 bpt (caddr (trans (caar lst) 0 vc1))
           )
           (LM:startundo (LM:acdoc))
           (foreach  itm (cdr lst)
               (setq ins (trans (car itm) 0 vc1))
               (aligntext:puttextinsertion 
                   (trans (list (car ins) (cadr ins) bpt) vc1 (cdr (assoc -1 (cadr itm))))
                   (cadr itm)
               )
           )
           (LM:endundo (LM:acdoc))
       )
   )
   (princ)
)

(defun aligntext:getdxfkey ( enx )
   (if
       (and
           (zerop (cdr (assoc 72 enx)))
           (zerop (cdr (assoc 73 enx)))
       )
       10 11
   )
)

(defun aligntext:gettextinsertion ( enx )
   (cdr (assoc (aligntext:getdxfkey enx) enx))
)

(defun aligntext:puttextinsertion ( ins enx )
   (   (lambda ( key )
           (if (entmod (subst (cons key ins) (assoc key enx) enx))
               (entupd (cdr (assoc -1 enx)))
           )
       )
       (aligntext:getdxfkey enx)
   )
)

;; Start Undo  -  Lee Mac
;; Opens an Undo Group.

(defun LM:startundo ( doc )
   (LM:endundo doc)
   (vla-startundomark doc)
)

;; End Undo  -  Lee Mac
;; Closes an Undo Group.

(defun LM:endundo ( doc )
   (while (= 8 (logand 8 (getvar 'undoctl)))
       (vla-endundomark doc)
   )
)

;; Active Document  -  Lee Mac
;; Returns the VLA Active Document Object

(defun LM:acdoc nil
   (eval (list 'defun 'LM:acdoc 'nil (vla-get-activedocument (vlax-get-acad-object))))
   (LM:acdoc)
)

(vl-load-com) (princ)

;;------------------------------------------------------------;;
;;                         End of File                        ;;
;;------------------------------------------------------------;;

 

I'm pleased that you find the program useful!

Posted

oh wow. thats awesome

i shall check this out when i get back to work first thing monday and let you know how it goes.

thanks so much for looking into that

Posted

You're welcome - I will also update the program on my site to incorporate this as an option.

 

Do you (and others) think the user should be prompted for a line spacing factor with the option to retain the existing spacing as a default? e.g.:

Specify line spacing factor <use existing spacing>:

Or should this be controlled by the parameter hard-coded into the program, which the user could set to nil to retain the existing spacing?

Posted

Think The ability for let user decide will save you request later. I would prefer that.

Posted

well for me personally i don't think i'd ever need to really use the vertical spacing. i'm mainly after it so i can make drawings alot neater without taking much time. if vertical spacing was changed then it would take to long adjusting all the leaders i think. if the leaders only have to stretch horizontally, then it doesn't take more than a few seconds to do. once the notes shift vertically then obviously leader ends need to move vertically as well as horizontally

 

if you look at these images you could imagine that if these notes moved vertically too, there would be alot more time/effort required to fix all the leader lines so they meet up with the notes again.

 

also the vertical position of my text is normally correct i think. I wouldn't want a note calling up reo towards bottom of plan end up being moved right up to the top. that doesn't really make sense.. and with equal vert spacing the notes could seem to blend into 1 giant note so having different spacing makes it bit easier to read i think

 

I am happy to have it as an option too. Just thought i'd explain how I would be using it

unaligned.jpg

aligned.jpg

Posted

Thank you both for the feedback, much appreciated. :thumbsup:

 

@masterfal, if you were to use MLeaders in your drawings, then these could be aligned using the standard MLEADERALIGN command. Nevertheless, I'm pleased to hear that you find my Align Text program useful, and that the modified program is working well in your drawings.

Posted

seems to work as described but doesn't pick mtext anymore.. (i think it did previously?)

 

theres another align text lsp I found a while ago which lets you select mtext/dtext and then after selection it shows a temporary line which moves to show where everything will line up to. The only prob with this is that for some reason it doesn't always work. I can select the text fine but when it comes to clicking a point to line up to, it won't always work. sometimes i need to click all over the place and finally it works or sometimes can't select a point at all. i've attached the lsp file in question. can anyone work out why this would be happening?

align.lsp

Posted
seems to work as described but doesn't pick mtext anymore.. (i think it did previously?)

 

My Align Text program was only ever written for use with single-line text.

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