can you set a visual lisp to run at half speed

can you set a visual lisp to run at half speed

Anonymous
Not applicable
1,114 Views
6 Replies
Message 1 of 7

can you set a visual lisp to run at half speed

Anonymous
Not applicable

I am making a 3D presentation in Autocad using visual lisp to move things in sequence, but it moves quickly and I want to know if there is a way to make commands move at half speed?

0 Likes
1,115 Views
6 Replies
Replies (6)
Message 2 of 7

Kent1Cooper
Consultant
Consultant

Welcome to these Forums!

 

I don't think so.  But if you can run the presentation from a SCRIPT rather than an AutoLisp routine, there's a DELAY command that will make pauses [in approximately thousandths of a second] between adjacent operations.  So you can [for example] have one thing moved, and put in DELAY 1000 to pause for about a second before it goes on to move the next thing.  However, the moving itself won't happen more slowly, if that's what you're after.

 

EDIT:  If delaying between things will do it for you, check out this thread about delays in AutoLisp, and Search for "delay in AutoLisp" to find more.  However, I find in a quick experiment that putting something like (command "_.delay" 3000) between something like two (command "_move" ...) functions doesn't work as I would expect -- it delays first, then does the two Move commands together and to all appearances instantaneously.  So the one about using the date would seem more reliable, though I haven't experimented with that.

Kent Cooper, AIA
0 Likes
Message 3 of 7

john.uhden
Mentor
Mentor

Here's something from over 15 years ago that's been waiting to be used.  I don't remember which one worked better, if at all.

 

(defun Wait (Seconds / stop)
  (setq stop (+ (getvar "date")(/ Seconds 86400.0)))
  (while (< (getvar "date") stop))
)

(defun Wait (Seconds)
  (setq i 1e6
        stop (+ i 10000)
        date1 (getvar "date")
  )
  (while (< i stop)(setq i (1+ i)))
  (setq date2 (getvar "date")
        elapsed (* (- date2 date1) 86400)
        i 0.0
        stop (* 0.85 (- Seconds elapsed)(/ 10000 elapsed))
  )
  (while (< i stop)(setq i (1+ i)))
  (rtos (* (- (getvar "date") date1) 86400) 2 4)
)
(defun Wait (Seconds)
  (setq i 0.0
        date1 (getvar "date")
  )
  (while (< i 10000)(setq i (1+ i)))
  (setq date2 (getvar "date")
        elapsed (* (- date2 date1) 86400)
        i 0.0
        stop (* 0.85 (- Seconds elapsed)(/ 10000 elapsed))
  )
  (while (< i stop)(setq i (1+ i)))
  (rtos (* (- (getvar "date") date1) 86400) 2 4)
)

John F. Uhden

0 Likes
Message 4 of 7

hgasty1001
Advisor
Advisor

Hi,

 

Just an idea: If you are moving objects along a known path, why not just make the movement more smooth using a very fine grained increment in each movement. I suppose that you have a curve object (an arc, line, polyline, etc) as a path, something like this in pseudo-code:

 

1.-Get the start parameter and end parameter of the intended path.

2.-Set the increment to a very little value, says 0.00001, you can fine tune this value.

3.- Set a parameter variable pv to the value of the start parameter

4.-Start a loop with the condition that terminates the loop when pv >= endparameter

3.-Move the object to the next point at the pv + increment

4.-Update pv to pv + increment

 

Gaston Nunez

 

 

Message 5 of 7

martti.halminen
Collaborator
Collaborator

 

These are all variations of busy-waiting, which generally has the problem that it tends to load the processor, making everything else done on the machine also slower. 

- one way of reducing the load: pad the loops with some slow, non-processor-intensive operations, for example calling directory listings from large directories, so the program is waiting at the operating system level for the disk reply, without loading the processor.

 

-- 

 

0 Likes
Message 6 of 7

rapidcad
Collaborator
Collaborator

If you can run dual monitor mode, or have only the AutoCAD window on your presentation screen, you should be able to use the VLIDE editor on your other screen to run your code, in Animated mode (Debug pulldown>Animate) after changing the delay in the Tools>Environment Options>General Options>Diagnostic tab>Delay control to something over 500 maybe?

 

With those settings if you run the function from the VLIDE visual lisp console you should be able to show the program at whatever number of millisecond delay works for your purposes. It should slow things down effectively.

 

Hope this helps,

 

Ron

ADN CAD Developer/Operator
Message 7 of 7

stevor
Collaborator
Collaborator
Another method, independent of 'time,' is for the presenter to initiate each next step. The simplest method is to the lsp execution at each step by a 'getstring for a key entry, by a 'grread when the pointer moves, or moves over specific area of the screen.
S
0 Likes