AutoLISP enter text

AutoLISP enter text

thomas.schive
Enthusiast Enthusiast
5,488 Views
5 Replies
Message 1 of 6

AutoLISP enter text

thomas.schive
Enthusiast
Enthusiast

Hello!

 

I quite recently began experimenting with AutoLISP, and was trying to write my own routine where I could add text along a chosen line with the z-coordinates to a chosen point along the line.

 

So far I've got like this:

 

(Defun c:hll()

(setq

pointa (getpoint "")

zvalue (caddr pointa)

); setq

 

Further on I thought of something like this (ofc not correctly written):

 

(command "text" *startingpoint = pointa* *height value* *rotation value* *text to be written = zvalue* "")

 

AND I would like this to go on/be repeated for every point the user wants to add, making it a loop. So that say if I got a 3D line and wants to create a small drawing which shows a chosen selection of heights, I can simply run my LISP and it will draw the text along the way as I just "click".  

 

Any tips for how I can proceed?

 

Regards, Thomas

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

dbroad
Mentor
Mentor

If you want to write this yourself, which I strongly encourage, you should run the text command yourself and collect the prompts.  Then write your command function.  Whenever you want to accept a default prompt, use "" in your command function.  When using the command function to add text however, you need to find out whether the current text style is a fixed height style and whether it is annotative.  The answers to your height questions will depend on those.

 

Try to avoid skipping prompts arguments in getpoint functions.

 

Good lisping.  Check out vlide too.

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 3 of 6

imadHabash
Mentor
Mentor

Hi,

 

i suggest also to visit and follow this FORUM and try to read more.

 

Good Luck..

Imad Habash

EESignature

0 Likes
Message 4 of 6

Ranjit_Singh
Advisor
Advisor
Accepted solution

@thomas.schive wrote:

..........

AND I would like this to go on/be repeated for every point the user wants to add, making it a loop. So that say if I got a 3D line and wants to create a small drawing which shows a chosen selection of heights, I can simply run my LISP and it will draw the text along the way as I just "click".  

 ........


If your text style is not a fixed height type, you receive a height prompt. In this case you could do something like

 

(defun c:somefunc  (/ pt)
 (while (setq pt (getpoint "\nSelect text location: "))
  (command "._text" pt 0.12 0 (rtos (caddr pt) 2 2))))

or like this for fixed height style font (notice 0.12 removed)

(defun c:somefunc  (/ pt)
 (while (setq pt (getpoint "\nSelect text location: "))
  (command "._text" pt 0 (rtos (caddr pt) 2 2))))

There is certainly more than one way of addressing both situations combined. Here is one example

;;Ranjit Singh
;;8/16/17
(defun c:somefunc (/ pt) (while (setq pt (getpoint "\nSelect text location: ")) (eval (append '(command "._text" pt) (if (zerop (cdr (assoc 40 (entget (tblobjname "style" (getvar 'textstyle)))))) '(0.12)) '(0 (rtos (caddr pt) 2 2))))))

3d_poly_z_elev.gif

Message 5 of 6

Kent1Cooper
Consultant
Consultant

You may find LabelElevMask.lsp of interest -- available here.

Kent Cooper, AIA
0 Likes
Message 6 of 6

thomas.schive
Enthusiast
Enthusiast

Great, thank you very much - this worked as planned!

0 Likes