TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: CatDance on September 10, 2021, 01:15:23 PM

Title: Do anyone have this Grread problem when running it in a big loop while
Post by: CatDance on September 10, 2021, 01:15:23 PM
I have no problem when running Grread in a big loop-while on Autocad 2002 (yes I know it is 2002 almost 20 years old version).

But now when I run the same code on Acad ver 2007, after a while the Autocad game hangs (showing the mouse cursor of a wheel loading icon) ?

Do anyone have this problem before ?
Title: Re: Do anyone have this Grread problem when running it in a big loop while
Post by: Lee Mac on September 10, 2021, 01:55:47 PM
Since AutoLISP evaluation is executed using the AutoCAD GUI processor thread, whilst the AutoLISP code is being evaluated, the AutoCAD application cannot communicate with the OS; and if the Windows OS does not receive any response from this thread within 5 seconds, the application is automatically marked as unresponsive and the cursor will display the processing donut icon.

The grread function (and, curiously, execution of the DELAY command) will temporarily return focus to the application thereby allowing communication with the host OS, and so I can only assume that more than 5 seconds elapse between successive calls to the grread function in your code when run within the 2007 environment.
Title: Re: Do anyone have this Grread problem when running it in a big loop while
Post by: CatDance on September 11, 2021, 01:27:41 AM
Since AutoLISP evaluation is executed using the AutoCAD GUI processor thread, whilst the AutoLISP code is being evaluated, the AutoCAD application cannot communicate with the OS; and if the Windows OS does not receive any response from this thread within 5 seconds, the application is automatically marked as unresponsive and the cursor will display the processing donut icon.

The grread function (and, curiously, execution of the DELAY command) will temporarily return focus to the application thereby allowing communication with the host OS, and so I can only assume that more than 5 seconds elapse between successive calls to the grread function in your code when run within the 2007 environment.

Hi Lee Mac,

wow ... this is deep. I have to read few times to understand it. I am not so good at this. Is there any way I can fix this ?
Title: Re: Do anyone have this Grread problem when running it in a big loop while
Post by: CatDance on September 11, 2021, 01:33:49 AM
One question - you said

whilst the AutoLISP code is being evaluated, the AutoCAD application cannot communicate with the OS ...

Why can't my Acad application cannot communicate with the OS ??
Title: Re: Do anyone have this Grread problem when running it in a big loop while
Post by: Crank on September 11, 2021, 08:38:18 AM
[...]
The grread function (and, curiously, execution of the DELAY command) will temporarily return focus to the application thereby allowing communication with the host OS
[...]
This is interesting!

I also have several lisps with a spinning donut. So what's the fastest function that can be used to keep Acad active during a loop?
Title: Re: Do anyone have this Grread problem when running it in a big loop while
Post by: Lee Mac on September 11, 2021, 07:06:11 PM
[...]
The grread function (and, curiously, execution of the DELAY command) will temporarily return focus to the application thereby allowing communication with the host OS
[...]
This is interesting!

I also have several lisps with a spinning donut. So what's the fastest function that can be used to keep Acad active during a loop?

The use of grread is the cleanest in my opinion, however this requires the user to move the mouse in order for evaluation to continue; otherwise, simply issue a call to the DELAY command - this has the same effect as a DoEvents call in VBA. Here's a related thread (https://www.theswamp.org/index.php?topic=50848.0) which might be of interest.
Title: Re: Do anyone have this Grread problem when running it in a big loop while
Post by: Crank on September 12, 2021, 05:02:14 AM
Thx
After reading that topic, I think I'll try the DELAY command.
Title: Re: Do anyone have this Grread problem when running it in a big loop while
Post by: CatDance on September 12, 2021, 10:08:20 AM


The grread function (and, curiously, execution of the DELAY command) will temporarily return focus to the application thereby allowing communication with the host OS ....

Can you give an example of the Delay command use ?

Oh sorry ... didn't see that . Now got it
it is ....
Code - Auto/Visual Lisp: [Select]
  1.  
  2. (defun foo ( n / x )
  3.     (setq x (getvar 'millisecs))
  4.     (while (< (- (getvar 'millisecs) x) n))
  5. )
  6. Code - Auto/Visual Lisp: [Select]
  7. (foo 2000) ;; no problem
  8. (foo 6000) ;; non-responsive for 1s
  9.  
  10.  
  11.