TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: mailmaverick on April 30, 2015, 12:21:19 AM

Title: DoEvents in LISP ?
Post by: mailmaverick 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 (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 ?

Title: Re: DoEvents in LISP ?
Post by: mailmaverick on May 03, 2015, 11:20:03 AM
Anyone ???
Title: Re: DoEvents in LISP ?
Post by: Lee Mac on May 03, 2015, 12:51:19 PM
The window freezes for this reason (http://bit.ly/1ca5JOs) - 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.
Title: Re: DoEvents in LISP ?
Post by: divtiply 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.
Title: Re: DoEvents in LISP ?
Post by: mailmaverick on May 05, 2015, 03:37:08 AM
The window freezes for this reason (http://bit.ly/1ca5JOs) - 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.
Title: Re: DoEvents in LISP ?
Post by: roy_043 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.
Title: Re: DoEvents in LISP ?
Post by: mailmaverick 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
Title: Re: DoEvents in LISP ?
Post by: roy_043 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.
Title: Re: DoEvents in LISP ?
Post by: Lee Mac 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.