Adding options to TEXT in lsp

Adding options to TEXT in lsp

Anonymous
Not applicable
1,268 Views
5 Replies
Message 1 of 6

Adding options to TEXT in lsp

Anonymous
Not applicable

Can I change the properties of a new TEXT object in lsp code?

 

Using the code given in this post:

http://forums.autodesk.com/t5/autocad-map-3d-forum/snap-mulktiple-text-objects-on-insertion/m-p/5341...

 

(setq a 0)
(defun RTX() (command "_TEXT" pause 10 0 (setq a (+ 1 a)))) 

I would also like to specify the justify property.

0 Likes
Accepted solutions (1)
1,269 Views
5 Replies
Replies (5)
Message 2 of 6

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

Can I change the properties of a new TEXT object in lsp code?

....

 

....
(defun RTX() (command "_TEXT" pause 10 0 (setq a (+ 1 a))))

I would also like to specify the justify property.


Just try it manually, take note of the prompts and your answers, and feed answers into the command in the proper sequence to answer the prompts, using pause for any place where the User would have to specify [such as the one above, which is pausing for the insertion point].  If you want to use a particular justification every time, you can simply build it in:

 

(defun RTX() (command "_TEXT" "_mc" pause 10 0 ....

 

[and yes, you can give it a justification abbreviation directlly, without going through the step of calling for the Justify option in the prompt].  If you want to call for Justification but have the User specify which one they want each time:

(defun RTX() (command "_TEXT" "_justify" pause pause 10 0 ....

Kent Cooper, AIA
Message 3 of 6

Anonymous
Not applicable

Thanks! For some reason "_tl" makes the text equal to the rotation and the rotation is 0. What did I do? I changed it like this:

 

(setq a 1)
(defun C:INSTXT() (command "_TEXT" pause 2 180 (setq a (+ 1 a))))
0 Likes
Message 4 of 6

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

Thanks! For some reason "_tl" makes the text equal to the rotation and the rotation is 0. What did I do? I changed it like this:

 

(setq a 1)
(defun C:INSTXT() (command "_TEXT" pause 2 180 (setq a (+ 1 a))))

Is that the right code?  It doesn't appear to have any Top-Left element, and the rotation should be 180.  The pause would for the insertion point, a height of 2 [only if the current Style does not have a fixed height], a rotation of 180, and text content which should be converted to a string, with (itoa).

Kent Cooper, AIA
Message 5 of 6

Anonymous
Not applicable

Thanks Kent. I took the "_tl" out because things were so wonky but I did realise that the text height was not needed. I didn't know that was why though.

 

I took out text height and put "_tl"back in in the correct place and voila, all is working. Thank you!

0 Likes
Message 6 of 6

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

... I did realise that the text height was not needed. I didn't know that was why though.

....


One thing you should consider is to incorporate the specification of the Text Style in the routine, so that it doesn't matter what Style may be current when you call it -- you'll always get the appropriate one for the purposes of this routine.  It could be either by a Style option within the Text command, or by setting the TEXTSTYLE System Variable first.  That way, you will know whether it has a fixed height, and can include or omit an answer to the height prompt as appropriate.

 

[In the case of some other Text-drawing routine that you may want to be able to use with whatever may be the current Text Style, it is possible for a routine to determine whether or not the current Style has a fixed height, and include or omit an answer to that prompt accordingly.]

Kent Cooper, AIA
0 Likes