while click point txt lsp

while click point txt lsp

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

while click point txt lsp

Anonymous
Not applicable

helper guys. I am learning lsp and making easy code.

 

(defun c:n (/ no siz pt)

(setq alf '("a20" "a75" "b40" "c30" "d10"))

(setq no 1)
(setq siz (* 3 (getvar "dimscale")))
(while (setq pt (getpoint "pick point :"))
(command "text" "m" pt siz 0 alf)
(setq no (1+ no))
)
(princ)
)

I made it but not working. some help please

if one click ---> a20

if 3 click  --->  a20 a75 b40

if 5 click --->  a20 a75 b40 c30 d10

I want to do this. thank you guys

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

_Tharwat
Advisor
Advisor

Hi,

Something like this?

(defun c:test (/ txt siz alf pt)
(setq alf '("a20" "a75" "b40" "c30" "d10"))
(setq txt "")
(setq siz (* 3 (getvar "dimscale")))
(foreach str alf
  (if (setq pt (getpoint "pick point :"))
    (command "text" "m" "_non" pt siz 0 (setq txt (strcat txt " " str)))
    )
  )
(princ)
)
0 Likes
Message 3 of 6

dbhunia
Advisor
Advisor

Hi,

 

Like this........

 

 

(defun c:N (/ txt siz alf pt)
(setq alf '("a20" "a75" "b40" "c30" "d10"))
(setq txt "")
(setq siz (* 3 (getvar "dimscale")))
(foreach st alf
(if (setq pt (getpoint "pick point :"))
(command "text" "m" pt siz 0 (setq txt (strcat txt " " st)))
)
)
(princ)
)


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 4 of 6

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

....

if one click ---> a20

if 3 click  --->  a20 a75 b40

if 5 click --->  a20 a75 b40 c30 d10

....


 

Assuming that you mean to apply the separate text strings in the list individually, one per picked location, and not as one string with spaces as other have assumed, try this:

(defun c:n (/ alf no siz pt)
  (setq alf '("a20" "a75" "b40" "c30" "d10"))
  (setq no 0)
  (setq siz (* 3 (getvar "dimscale")))
  (while
    (and
      (< no (length alf)); still any left
      (setq pt (getpoint "pick point :"))
    ); and
    (command "text" "m" pt siz 0 (nth no alf))
    (setq no (1+ no))
  )
(princ)
)  

 

Kent Cooper, AIA
0 Likes
Message 5 of 6

Anonymous
Not applicable

always thank you                              

sooooo good

0 Likes
Message 6 of 6

dbhunia
Advisor
Advisor

@Anonymous wrote:

helper guys. I am learning lsp and making easy code.

 .........

I made it but not working. some help please

if one click ---> a20

if 3 click  --->  a20 a75 b40

if 5 click --->  a20 a75 b40 c30 d10

.......


 

Hi Union,

 

I am glad you got your solution.......

 

But in your query you asked you want something like that.......

 

if one click ---> a20

if 3 click  --->  a20 a75 b40

if 5 click --->  a20 a75 b40 c30 d10

 

So accordingly I & @_Tharwat changes your program ......... for your requirement....


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....