Author Topic: DoEvents in LISP ?  (Read 5336 times)

0 Members and 1 Guest are viewing this topic.

mailmaverick

  • Bull Frog
  • Posts: 493
DoEvents in LISP ?
« on: April 30, 2015, 12:21:19 AM »
When my LISP routine takes long time to execute, the window freezes.

I use (acet-ui-status .....) along with (vla-eval (vlax-get-acad-object) "DoEvents")

This solves my purpose. But for DoEvents to work, VBA Module needs to be installed from following link :-

http://knowledge.autodesk.com/support/autocad/downloads/caas/downloads/content/download-the-microsoft-visual-basic-for-applications-module.html

Now, in my computer, I have VBA module installed. But when I run this LISP in any other computer where VBA is not installed, it gives error.

Is it possible to do DoEvents in LISP ?

Or otherwise, any other solution to stop window freeze ?


mailmaverick

  • Bull Frog
  • Posts: 493
Re: DoEvents in LISP ?
« Reply #1 on: May 03, 2015, 11:20:03 AM »
Anyone ???

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: DoEvents in LISP ?
« Reply #2 on: May 03, 2015, 12:51:19 PM »
The window freezes for this reason - as far as I am aware, there is no way around this using only AutoLISP, unless you continously accept user input via grread whilst processing.

divtiply

  • Guest
Re: DoEvents in LISP ?
« Reply #3 on: May 04, 2015, 01:07:50 AM »
There is an ARX solution -- http://www.maestrogroup.com.ua/support/ProgressBars.zip
Use (onidleacad [time-interval]) in your main loop.

mailmaverick

  • Bull Frog
  • Posts: 493
Re: DoEvents in LISP ?
« Reply #4 on: May 05, 2015, 03:37:08 AM »
The window freezes for this reason - as far as I am aware, there is no way around this using only AutoLISP, unless you continously accept user input via grread whilst processing.

Can we use grread with a timer, say 0.01 seconds in which it will wait for user input (dummy input) for 0.01 seconds and if it doesn't get it, then the program execution will proceed. That way maybe we can refresh the screen during LISP routine.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: DoEvents in LISP ?
« Reply #5 on: May 05, 2015, 05:57:25 AM »
I seem to recall a recent similar topic where using (grtext -1 str) in each loop solved the problem.
Can't find it though.

mailmaverick

  • Bull Frog
  • Posts: 493
Re: DoEvents in LISP ?
« Reply #6 on: May 05, 2015, 10:09:56 AM »
I seem to recall a recent similar topic where using (grtext -1 str) in each loop solved the problem.
Can't find it though.

R U talking about this thread : http://www.theswamp.org/index.php?topic=25336.5

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: DoEvents in LISP ?
« Reply #7 on: May 06, 2015, 04:53:30 AM »
I seem to recall a recent similar topic where using (grtext -1 str) in each loop solved the problem.
Can't find it though.

R U talking about this thread : http://www.theswamp.org/index.php?topic=25336.5
No.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: DoEvents in LISP ?
« Reply #8 on: May 06, 2015, 05:07:39 AM »
Here is a very simple example to demonstrate how grread may be used to prevent freezing/non-responsiveness whilst processing:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:10secprocess ( / t1 t2 )
  2.     (alert
  3.         (strcat
  4.             "The following process will take 10 seconds."
  5.             "\nThe AutoCAD window will not freeze during this time."
  6.         )
  7.     )
  8.     (setq t1 (getvar 'millisecs)
  9.           t2 (+ 10000 t1)
  10.     )
  11.     (acet-ui-progress-init "Processing..." 10500) ;; 10s + some tolerance
  12.     (while (< (getvar 'millisecs) t2)
  13.         (grread t)
  14.         (acet-ui-progress-safe (- (getvar 'millisecs) t1))
  15.     )
  16.     (acet-ui-progress-done)
  17.     (princ)
  18. )

Any slight movement of the mouse will suffice whilst the program is running to ensure processing continues.