Using Delay command in scripts

Using Delay command in scripts

david.elgart
Observer Observer
5,086 Views
5 Replies
Message 1 of 6

Using Delay command in scripts

david.elgart
Observer
Observer

Hi, I apologize in advance if this is dumb or obvious since I'm fairly new to using scripts, but I wanted to try out using the DELAY command in between other commands in a script, just to space things out so everyting doesn't pop up at once.

 

For a test run I just ran this very simple Notepad script:

 

line
0,0
0,5

Delay 2000
Line
0,5
5,5

 

 However, in this case and others I have attempted, always brings the DELAY command into action prior to any other commands, so instead of pausing in between these lines, it is instead pausing at the very beginning of the script. In scripts where I placed multiple delays in between multiple commands, the same occurs, but adding the total delay time to the beginning.

So my question is, is there any way to get the delay to occur in between my commands? Or is it specifically used for slide shows?

(I'm using AutoCAD 2014)

 

Thanks

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

dbroad
Mentor
Mentor

The delay command is intended for use in scripts that display slides.  It can be invoked transparently but the effects won't be seen as staged unless you invoke 'redraw or (vla-date (vlax-get-acad-object)) between delayed steps.  Here is a sample that works here.

(defun c:test ()
  (setq acd (vlax-get-acad-object))
  (command "line" "0,0")
  (command "'delay" "2000")
  (vla-update acd)
  (command "5,0")
  (vla-update acd)
  (command "'delay" "2000")
  (vla-update acd)
  (command "5,5")
  (vla-update acd)
  (command "'delay" "2000")
  (vla-update acd)
  (command "0,5")
  (vla-update acd)
  (command "'delay" "2000" "cl")
  (princ)
)

 I'm not sure this is the best approach though.  BTW, for an equivalent script file:

LINE

0,0

'DELAY 2000

'REDRAW

5,0

'DELAY 2000

'REDRAW

5,5

'REDRAW

'DELAY 2000

ETC

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

david.elgart
Observer
Observer

Thanks, unfortunately I hadn't been acquainted with AutoLisp yet, but it worked just fine with the delays after I looked up how to execute it in AutoCad. I then tried using the 'REDRAW command with the script from my original post, but it still placed the delays at the beginning of the script as opposed to between the line/redraw commands. I don't quite understand the differences between the two but the .lsp file worked and .scr didn't.

 

Thanks for your help though!

0 Likes
Message 4 of 6

BeKirra
Advisor
Advisor

I dig this old thread out while I search for the use of command "delay". I confuse with the input for command "Delay".

Will it be an integer or string?

I don't see explanation in HELP.

I find both seem ok

(command "delay" 50)
(command "delay" "50")

 

Your helps are much appreciated.

 

Please mark "Accept as Solution" and "Like" if my reply resolves the issue and it will help when others need helps.
= ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ =
A circle is the locus of a cursor, starting and ending at the same point on a plane in model space or in layout such that its distance from a given coordinates (X,Y) is always constant.
X² + Y² = C²
0 Likes
Message 5 of 6

Kent1Cooper
Consultant
Consultant

Either way works in a (command) function, so you may as well save yourself a couple of code characters and omit the quotation marks.  In a DELAY command at the command line, it is not accepted with quotation marks.  [And it doesn't matter to the answer, but you'll never notice a DELAY of 50 milliseconds.]

Kent Cooper, AIA
Message 6 of 6

BeKirra
Advisor
Advisor

@Kent1Cooper wrote:

Either way works in a (command) function, so you may as well save yourself a couple of code characters and omit the quotation marks.  In a DELAY command at the command line, it is not accepted with quotation marks.  [And it doesn't matter to the answer, but you'll never notice a DELAY of 50 milliseconds.]


Thanks Kent. You are right. It doesn't accept any string when enter input in command line. Here is an example.

 

Command: DELAY
Enter delay time (in milliseconds): "500"

Requires an integer between 0 and 32767.
Enter delay time (in milliseconds): 500

 

Please mark "Accept as Solution" and "Like" if my reply resolves the issue and it will help when others need helps.
= ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ =
A circle is the locus of a cursor, starting and ending at the same point on a plane in model space or in layout such that its distance from a given coordinates (X,Y) is always constant.
X² + Y² = C²
0 Likes