Delay between commands

Delay between commands

anieves228
Enthusiast Enthusiast
1,463 Views
5 Replies
Message 1 of 6

Delay between commands

anieves228
Enthusiast
Enthusiast

Hi peeps! 

 

So im trying to create a delay between commands, but instead of the delay pausing between commands, it delays the entire defun. I know I've done this before, i just can't remember how. What am i doing wrong?

 

For example, the delay command will run before the zoom extents instead of after.

 

(defun c:PI()

(command "z" "e")

(command "delay" "3000")

(command "z" "a")

)

 

0 Likes
1,464 Views
5 Replies
Replies (5)
Message 2 of 6

Kent1Cooper
Consultant
Consultant

@anieves228 wrote:

... the delay command will run before the zoom extents instead of after. .... 


 

Are you sure that's what's happening?  When I use your code, changing it to "2x" and "0.5x" to Zoom in and back out, so I can be certain of seeing what happens, I get an error that it doesn't recognize "z" as a command name.  That happens before and after the delay.  If I spell out the full command name, it works fine, with the delay between the Zooms.  And it does the same when consolidated into one  (command) function:

  (command "_.zoom" "2x" "_.delay" "3000" "_.zoom" "0.5x")

 

[I changed it to Zoom in and out instead of to Extents and All, because depending on what's drawn those latter can sometimes end up with the same result, so you might not be able to tell when it did which, i.e. whether the delay was between them or before both.  But that's assuming something about your setup is different enough from mine that it does  recognize plain "z" as a command name.]

Kent Cooper, AIA
0 Likes
Message 3 of 6

ВeekeeCZ
Consultant
Consultant

@Kent1Cooper wrote:

@anieves228 wrote:

... the delay command will run before the zoom extents instead of after. .... 


 

Are you sure that's what's happening?  ...


 

The same as the OP's here, take a LOOK ... or THIS ONE is probably better.

ACAD 2019, W8.1, IntelGraphic. 

0 Likes
Message 4 of 6

Kent1Cooper
Consultant
Consultant

[Well, with that Line-delay-Zoom combination, I get the same "problem" that I don't  have with the Zoom-in-delay-Zoom-out one.  I have no idea what makes the difference.]

Kent Cooper, AIA
0 Likes
Message 5 of 6

martti.halminen
Collaborator
Collaborator

Another funny thing: when I try that from AutoCAD command line, no zooming visible, but running from Vlide console window, works OK.

-- 

 

0 Likes
Message 6 of 6

CodeDing
Advisor
Advisor

I very frequently come across the issue when I want to zoom before running more code, but it runs the next code anyways. I am not sure why this happens.

Anyway, this seemed to work for me. Give it a try:

(defun c:PI()
(command-s "_.ZOOM" "e")
(command-s "_.REGEN")
(command "delay" "3000")
(command "_.ZOOM" "a")
)

But it is unknown to me what exactly you are trying to accomplish by running this.

Best,

~DD

0 Likes