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

0 Members and 1 Guest are viewing this topic.

ribarm

  • Gator
  • Posts: 3225
  • 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...

[EDIT : Superman *.pat file was attached to this post at cadtutor... I had to scale down DWG 10x smaller size and do fixing lines to SNAP points of 0.5,0.5, before applying lastly posted code from cadtutor link... ACAD did the job corrctly and BCAD didn't do like ACAD... So altough slower ACAD is still better IMHO...
Here is the link for *.pat file : https://www.cadtutor.net/forum/topic/70417-make-pat-files/?do=findComment&comment=574183
]
« Last Edit: November 15, 2020, 06:19:13 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3225
  • 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

  • Water Moccasin
  • Posts: 1626
  • 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

  • Gator
  • Posts: 3225
  • 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: 17750
  • Have thousands of dwgs to process? Contact me.
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
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

ribarm

  • Gator
  • Posts: 3225
  • 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: 17750
  • Have thousands of dwgs to process? Contact me.
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.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
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.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

ribarm

  • Gator
  • Posts: 3225
  • 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: 17750
  • Have thousands of dwgs to process? Contact me.
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.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

VovKa

  • Water Moccasin
  • Posts: 1626
  • 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: 17750
  • Have thousands of dwgs to process? Contact me.
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:

Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: LISP sometimes not possible to kill with ESC...
« Reply #27 on: January 24, 2021, 05:06:46 AM »
I want to ask someone, can this issue be sent to AutoDesk for consideration for future... Simply I want that ACAD handles ESC within itself by terminating routine workflow and not to make ACAD not responding and making Windows in charge from which you can only terminate ACAD session... I want session active, terminated routine and nothing more... So can this (while, repeat, foreach... recursion) looping be implemented differently not to disturb its performance, but to allow termination...
I am reviving this topic as it's so evidently important and incredibly relevant for working with LISP and ACAD generally... When I say ESC for termination, I also mean every routine *.dll, *.lsp, *.arx, *.vlx, ...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

BIGAL

  • Swamp Rat
  • Posts: 1396
  • 40 + years of using Autocad
Re: LISP sometimes not possible to kill with ESC...
« Reply #28 on: January 24, 2021, 07:09:41 PM »
Agree with you sometimes accidently send a lisp into a infinite loop no exit and majority of times a kill via task manager is only way to stop, recognising Ctrl+break would be helpful.
A man who never made a mistake never made anything