Author Topic: LISP sometimes not possible to kill with ESC...  (Read 934 times)

0 Members and 1 Guest are viewing this topic.

ribarm

  • Water Moccasin
  • Posts: 2335
  • Marko Ribar, architect
Re: LISP sometimes not possible to kill with ESC...
« Reply #15 on: May 06, 2020, 10:35:48 AM »
Quote
Code: [Select]
...Unknown Error in Lisp or CAD system or 'Stack Overflow'


Here is my testing project in ZIP...
BricsCAD can hatch *.pat file, but AutoCAD can't... But AutoCAD calculated *.pat and BricsCAD failed with above mentioned error...
Do happen to know why there are errors in BricsCAD presentation of *.pat file... According to LISP there should be no errors and lacks... If you see something in my code that you think is bad, please enlighten me...
I thought that BricsCAD will calculate differently, but it failed... And BTW, I tried to interrupt calculation and when I appended *.txt file to *.pat I did get differently then *.pat calculation in one go... So still somethings wrong with my codes, but I can't quite find out what...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Water Moccasin
  • Posts: 2335
  • Marko Ribar, architect
Re: LISP sometimes not possible to kill with ESC...
« Reply #16 on: May 13, 2020, 08:03:15 AM »
Just to inform... This topic is still not solved... I run my routine again and still white screen appears after ESC... So this thing with (_do-events) doesn't really solves it... We need more methods and options to consider... Yes the problem is (while/repeat/foreach/recursion) looping, but how to solve this problem more reliably? Note sometimes this thingy (_do-events) is not applicable (foreach/recursion)... So are there any new tricks?

[EDIT : I am not saying that it isn't possible to implement (_do-events) and for (foreach/recursion), but the thing is that it slows things and still not 100% reliable...]
« Last Edit: May 13, 2020, 08:15:56 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

VovKa

  • Swamp Rat
  • Posts: 1223
  • Ukraine
Re: LISP sometimes not possible to kill with ESC...
« Reply #17 on: May 13, 2020, 09:58:08 AM »
Marko you want to do-events only with lisp? no arx?

ribarm

  • Water Moccasin
  • Posts: 2335
  • Marko Ribar, architect
Re: LISP sometimes not possible to kill with ESC...
« Reply #18 on: May 13, 2020, 10:46:24 AM »
Marko you want to do-events only with lisp? no arx?

I want to make this routine working as it's supposed to, so that when I hit ESC, it quits 100% reliably without going to white screen (Windows application - not responding - i.e. AutoCAD)...
https://www.cadtutor.net/forum/topic/70417-make-pat-files/?do=findComment&comment=565434
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

MP

  • Seagull
  • Posts: 17631
Re: LISP sometimes not possible to kill with ESC...
« Reply #19 on: May 13, 2020, 10:56:54 AM »
;;  My very quick perusal of your code suggests you're using (_do-events) very
;;  heavy handedly, i.e. invoking it every pass thru iteration loops. Do this instead:

;;  before loop

(setq
    i      0
    cycles 5000 ;; determine optimal value empirically
)


;; in processing loop

(if (zerop (rem (setq i (1+ i)) cycles)) (_do-events))

;;  cheers
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

ribarm

  • Water Moccasin
  • Posts: 2335
  • Marko Ribar, architect
Re: LISP sometimes not possible to kill with ESC...
« Reply #20 on: May 13, 2020, 11:25:08 AM »
I am doing what you suggested... And I've put 2000 instead of 5000, so I am betting on better response on ESC... I hope my code is then finished as I wanted. Now if white screen pops up again, I hope it's not by me and badly coding...  :mrgreen:
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

MP

  • Seagull
  • Posts: 17631
Re: LISP sometimes not possible to kill with ESC...
« Reply #21 on: May 13, 2020, 11:41:26 AM »
I am doing what you suggested...

Not entirely. You defined the do-events function using vl-cmdf instead of command. Use the latter.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

MP

  • Seagull
  • Posts: 17631
Re: LISP sometimes not possible to kill with ESC...
« Reply #22 on: May 13, 2020, 12:04:02 PM »
Really long processes might benefit from this if AutoCAD loses focus:

Code: [Select]
(defun _doc ( )
    (vl-load-com)
    (setq *doc* (vla-get-activedocument (vlax-get-acad-object)))
    (defun _doc ( ) *doc*)
    *doc*
)

(defun _do-events ( / cmdecho )
    (setq cmdecho (getvar 'cmdecho))
    (setvar 'cmdecho 0)
    (gc)
    (vla-activate (_doc)) ;; <<--- new
    (repeat 2 (command ".delay" 0) (princ ""))
    (setvar 'cmdecho cmdecho)
    (princ)
)

Concept code; untested.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

ribarm

  • Water Moccasin
  • Posts: 2335
  • Marko Ribar, architect
Re: LISP sometimes not possible to kill with ESC...
« Reply #23 on: May 13, 2020, 12:43:08 PM »
It's just me...
I prefer using (vl-cmdf) instead of both (command) and (command-s) predominately from this reasons...
In later versions of AutoCAD (command-s) was suggested to be used in error handlers if you want to use command calls, but in older versions (command-s) isn't implemented... So I experimented and I came to conclusion that (vl-cmdf) also behaves correctly in error handlers and BTW. it exist in all ACAD versions since also (command) function was introduced in ALISP... Further investigations showed that timings of execution was fastest with (vl-cmdf) - just very very small difference than (command-s)... (command) was slowest according to my testings... So if you think more over it, no matter it returns T and not nil, (vl-cmdf) can very well substitute both (command) and (command-s)... One more fact in favor of (vl-cmdf) : (command-s) must have supplied all tokens in single expression wihout breaking syntax... (vl-cmdf) here bahaves like (command), you simply can use it like this :

Code: [Select]
(vl-cmdf "_.PLINE")
(foreach p pl
  (vl-cmdf "_non" p)
)
(vl-cmdf "")

Or this snippet :

Code: [Select]
(vl-cmdf "_.PLINE")
(while (< 0 (getvar 'cmdactive))
  (vl-cmdf "\\")
)

(command-s) can't imitate this behaviour...
You'd have to do someting like this :

Code: [Select]
(apply 'command-s (cons "_.PLINE" (append (apply 'append (mapcar '(lambda ( x ) (list "_non" x)) pl)) (list ""))))

But that syntax is crazy IMHO...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

MP

  • Seagull
  • Posts: 17631
Re: LISP sometimes not possible to kill with ESC...
« Reply #24 on: May 13, 2020, 12:57:48 PM »
While I use vl-cmdf / command-s where applicable in my coding none of the "benefits" are applicable for this context imo, especially speed. Cheers.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

VovKa

  • Swamp Rat
  • Posts: 1223
  • Ukraine
Re: LISP sometimes not possible to kill with ESC...
« Reply #25 on: May 13, 2020, 04:26:00 PM »
I want to make this routine working as it's supposed to
this is clear

what i meant was that you can try onidleacad function from ProgressBars arx library by Alexander Rivilis
original post https://www.theswamp.org/index.php?topic=8570.msg115457#msg115457
latest version http://www.maestrogroup.com.ua/support/ProgressBars.zip

MP

  • Seagull
  • Posts: 17631
Re: LISP sometimes not possible to kill with ESC...
« Reply #26 on: May 13, 2020, 04:48:06 PM »
what i meant was that you can try onidleacad function from ProgressBars arx library by Alexander Rivilis
original post https://www.theswamp.org/index.php?topic=8570.msg115457#msg115457
latest version http://www.maestrogroup.com.ua/support/ProgressBars.zip

Nice, Alexander Rivilis' work is top notch.

If you're going the third party route there's also DOS_LIB's dos_getprogress function:

\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox