align text

align text

ami
Contributor Contributor
2,965 Views
4 Replies
Message 1 of 5

align text

ami
Contributor
Contributor

Hi every one,

Can someone help me with a lisp that align text this way:

when calling the lisp it asks "right / Left" , if I click left ,and click on a text1 and text2 it will align them text2 after text1 from left to right ( but only with one space between them not connected),and when I click text3 it will add him the same way after text 2, until I right click my mouse and it will break the command.

And if I click Right it will do the same but will add the text one after another from right to left.

 

It will be very helpfull for me,

Thank you in advance.

Eyal

 

0 Likes
Accepted solutions (1)
2,966 Views
4 Replies
Replies (4)
Message 2 of 5

ВeekeeCZ
Consultant
Consultant

Post an example dwg with before and after.

0 Likes
Message 3 of 5

ami
Contributor
Contributor

Hi,

here is a dwg as I want:

https://drive.google.com/file/d/1NvpCJYse3tEakYCvY6VHyIcXr4CiZ2Gq/view?usp=sharing

The message that I want to apear at the start is :

https://drive.google.com/file/d/1mWRwVW9C888naFX5yL6CbKi0GqbELLv3/view?usp=sharing

 

Here is a code similar to what I want :

(princ "\CT.LSP (Combine Text) - Matt Pittman\n")
(defun C:ct (/ );1strg text1 t1 spc 2strg text2 t2 comb)
(setq 1strg (entget (car (entsel "\nPick 1st Text.. "))))
(setq text1 (assoc 1 1strg))
(setq t1 (cdr (assoc 1 1strg)))
(setq spc " ")
(setq 2string (entsel "\nPick 2nd Text.. "))
(setq 2s (car 2string))
(setq 2strg (entget (car 2string)))
(setq text2 (assoc 1 2strg))
(setq t2 (cdr (assoc 1 2strg)))
(entdel 2s)
(setq comb (strcat t1 spc t2))
(setq comb (cons 1 comb))
(setq 1strg (subst comb text1 1strg))
(entmod 1strg)
(princ)
)

but I want that at first it will asks for right or left and then after clicking the first text1 it will say add text and then I click text2 and it will put it after the text with one space but with no connection ( seperate texts), 

and I can continue clicking another texts and it will add them after the text2 etc, and when I right click it will finish the command.

The same thing if I choose Right , but it will add the texts one after another from right to left.

I hope I clear now.

 

Thank you,

Eyal

 

0 Likes
Message 4 of 5

Kent1Cooper
Consultant
Consultant
Accepted solution

@ami wrote:

... I want that at first it will asks for right or left and then after clicking the first text1 it will say add text and then I click text2 and it will put it after the text with one space but with no connection ( seperate texts), 

and I can continue clicking another texts and it will add them after the text2 etc, and when I right click it will finish the command.

....


 

Give the attached TextRow.lsp a try.  See the comments at the top.

 

It doesn't place things apart by "one space" in the text-character sense, but by "some  space," which I chose to be half the text height of the initial object, but you can adjust that.  [It could  be made to actually make it the true size of a space in the Style and height of the initial object, but it would mean creating a temporary and invisible Text object with one space as its content, and getting its bounding box to determine the gap size.  It should be able to delete that before proceeding, but it seems "risky" to create an object that can't be seen or selected later if somehow it doesn't get deleted.]

 

It works with multiple Text/Mtext objects of different heights from each other, but the gap between all of them will be half the text height of the first  one selected.

 

If you want Text baselines  to line up, rather than bounding-box bottom edges, and  if you would always be selecting only  plain-Text objects, that could probably be worked out, but it would be more complicated.

Kent Cooper, AIA
Message 5 of 5

ami
Contributor
Contributor

P E R F E C T ! ! ! 

Thank you very much! @Kent1Cooper , it will be very usefull for me.

Eyal

0 Likes