Waiting for command to finish in AutoLISP

Waiting for command to finish in AutoLISP

326047736
Contributor Contributor
529 Views
2 Replies
Message 1 of 3

Waiting for command to finish in AutoLISP

326047736
Contributor
Contributor

Hello everyone.

 

I'm trying to wait for the boundary command to finish in AutoLISP. So I tried the code below:

 

 

(command "_.-boundary")
(while (> (getvar 'cmdactive) 0) (command pause))
(command "move" (entlast))

 

 

But I mysteriously can't select all the options of the command:

 

demo.gif

 

So I changed a little bit of the code:

 

 

(command "_.-boundary")
(while (= (getvar "CMDNAMES") "boundary") (command pause))
(print "Hello!")

 

 

AutoLISP didn't "wait" for the command to finish and printed "Hello!" on the console directly:

 

demo2.gif

 

What should I have a try next?

 

Any reply might be helpful. Thanks!

0 Likes
Accepted solutions (1)
530 Views
2 Replies
Replies (2)
Message 2 of 3

ВeekeeCZ
Consultant
Consultant
Accepted solution

Your comparison fails. See HERE 

 

It seems that 'cmdactive method works fine for me.

You can also try (command-s "-boundary") method if you have acad 2016+

0 Likes
Message 3 of 3

326047736
Contributor
Contributor

Thanks a lot! @ВeekeeCZ 

 

Command-s works great (on AutoCAD 2020) and I should really check the comparison result first.😅

0 Likes