TemporaryCAD Posted September 27, 2022 Posted September 27, 2022 I'm trying to share some of my code with my coworkers, but when they try to run it I am encountering errors I cannot reproduce. The most annoying is when trying to run a lisp they just get the message ;error quit exit/abort. I cannot reproduce the problem, and others, who are running the same code on the same autocad version, are not experiencing the issue. I'm hoping someone here has the knowledge to figure out how to fix this. I'm getting some google results but so far nothing has worked. Quote
tombu Posted September 27, 2022 Posted September 27, 2022 Without seeing the code it would be hard to debug but I'd guess the lisp includes command calls but doesn't account for differences in system variables that affect those commands. You're not giving us much to go on. Quote
mhupp Posted September 27, 2022 Posted September 27, 2022 (edited) sounds like someone is hitting esc in the middle of your lisp or you have an if statement that triggers (quit) Give this a read. http://www.lee-mac.com/errorhandling.html (defun c:test ( / *error* osm ) (defun *error* ( msg ) (if osm (setvar 'osmode osm)) ;set old sys var back to orginal state (if (not (member msg '("Function cancelled" "quit / exit abort"))) ;if error contains any of the following do nothing (princ (strcat "\nError: " msg)) ;else display the error msg ) (princ) ) .... rest of code ) Edited September 27, 2022 by mhupp Quote
BIGAL Posted September 27, 2022 Posted September 27, 2022 (edited) exit esc abort look for (EXIT) in code, sounds like something I would do though only in coding and testing when I want it to stop it is a hard stop. (exit) ; error : quit / exit abort Now you know need the lisp to see why its exiting, sort of thing where stop endless loop if = 100 (exit) Edited September 27, 2022 by BIGAL Quote
tombu Posted September 28, 2022 Posted September 28, 2022 TEXT, LEADER, POLYLINE & other commands are affected by settings, system variables and even product version. If you don't want to let us to fix your code just tell us what you want it to do and one of us will give you something debugged to work on different PC's you can replace it with. If you decide to post the code put it in the window after clicking <> on the toolbar and change it to "No Syntax Highlighting" from "HTML". Quote
Jonathan Handojo Posted September 28, 2022 Posted September 28, 2022 Many possible factors are there. With programming, all sorts of things could be the case. For example, one scenario could be that your LISP code might be using subfunctions which are loaded from a separate saved .lsp file that exists only in your computer and not others. Your error handler is programmed to return the said error message. That being said, none of us here will know the real issue unless you give us the details by sharing the code. If you're still not willing to do so, the best advice I can give you is that you will need to debug it yourself in your coworker's computer to truly find out why the code is failing. Lee Mac has a tutorial explaining how to go about it. Follow the steps here and you'll be able to debug just about any failing program. Though unfortunately, this doesn't exist from AutoCAD version 2021 and beyond, which is why I keep a 2019 version just in case for this. Quote
tombu Posted September 28, 2022 Posted September 28, 2022 41 minutes ago, Jonathan Handojo said: If you're still not willing to do so, the best advice I can give you is that you will need to debug it yourself in your coworker's computer to truly find out why the code is failing. Lee Mac has a tutorial explaining how to go about it. Follow the steps here and you'll be able to debug just about any failing program. Though unfortunately, this doesn't exist from AutoCAD version 2021 and beyond, which is why I keep a 2019 version just in case for this. The VLIDE is still available in new versions. Just set LISPSYS (System Variable) to 0, however AutoLISP functions wouldn't fully support Unicode characters. AutoLISP source (LSP) files when saved and compiled use the ASCII (MBCS) character set which is no longer the standard anywhere. Note: This setting results in the behavior of AutoCAD 2020 and earlier releases, and is supported on Windows only. Quote
TemporaryCAD Posted September 28, 2022 Author Posted September 28, 2022 12 hours ago, BIGAL said: exit esc abort look for (EXIT) in code, sounds like something I would do though only in coding and testing when I want it to stop it is a hard stop. (exit) ; error : quit / exit abort Now you know need the lisp to see why its exiting, sort of thing where stop endless loop if = 100 (exit) The only time (exit) is called is in the following lines: (setq dcl_id (load_dialog "titleblockdcl.dcl")) (if (not (new_dialog "main" dcl_id)) (exit) ) What would cause (new_dialog) to fail on only certain computers, all running the same code and dcl files from the same location? I'll be honest, I do not deeply understand (new_dialog) as it would always work on my computer. Quote
tombu Posted September 28, 2022 Posted September 28, 2022 3 minutes ago, TemporaryCAD said: What would cause (new_dialog) to fail on only certain computers, all running the same code and dcl files from the same location? I'll be honest, I do not deeply understand (new_dialog) as it would always work on my computer. Make sure "titleblockdcl.dcl" is saved in a folder both in Support File Search Path and Trusted Folders on their PC. Test by entering (load_dialog "titleblockdcl.dcl") at their command line. Quote
mhupp Posted September 28, 2022 Posted September 28, 2022 I always write the dcl file into the lisp so there is only one file to keep track of. @rlx has a nice converter. https://www.cadtutor.net/forum/topic/66737-convert-dcl-file-to-lisp-file/ (setq fo (open (setq fn (vl-filename-mktemp "" "" ".dcl")) "w")) ;will make a temp file in your temp folder location (write-line "each line of your dcl" fo) ; rlx file convert file here. ... (close fo) (new_dialog "foo" (setq d (load_dialog fn))) ;load like normal ... (vl-file-delete fn) ;deletes temp file from first line. 1 Quote
dania Posted September 2, 2023 Posted September 2, 2023 ;;;Cadalyst AutoLISP Solutions July 2007 ALSPSOL0707.ZIP / ADARRAY.LSP (c) Tony Hotchkiss ;;; (defun err (s) (if (= s "Function cancelled") (princ "\nADARRAY - cancelled: ") (progn (princ "\nADARRAY - Error: ") (princ s) (terpri) ) ;_ progn ) ;_ end of if (resetting) (princ "SYSTEM VARIABLES have been reset\n") (princ) ) ;_ end of err (defun setv (systvar newval) (setq x (read (strcat systvar "1"))) (set x (getvar systvar)) (setvar systvar newval) ) ;_ end of setv (defun setting () (setq oerr *error*) (setq *error* err) (setv "CMDECHO" 0) (setv "BLIPMODE" 0) (setv "OSMODE" 0) (setv "CLAYER" (getvar "CLAYER")) ) ;_ end of setting (defun rsetv (systvar) (setq x (read (strcat systvar "1"))) (setvar systvar (eval x)) ) ;_ end of rsetv (defun resetting () (rsetv "CMDECHO") (rsetv "BLIPMODE") (rsetv "OSMODE") (rsetv "CLAYER") (setq *error* oerr) ) ;_ end of resetting (defun adarray () (vl-load-com) (setq *thisdrawing* (vla-get-activedocument (vlax-get-acad-object) ) ;_ end of vla-get-activedocument *modelspace* (vla-get-ModelSpace *thisdrawing*) ) ;_ end of setq (setq bnameindex nil) (setq doit 4) (setq ad_id (load_dialog "adarray.dcl")) (while (>= doit 2) (if (not (new_dialog "adarray" ad_id)) (exit) ) ;_ end of if (init-array) (action_tile "bname" "(setq bnameindex (atoi $value))") (action_tile "row" "(setq *rowdist* (atof $value))") (action_tile "col" "(setq *coldist* (atof $value))") (action_tile "pick" "(done_dialog 3)") (action_tile "accept" "(get-adarray-data) (done_dialog 1)" ) ;_ end of action_tile (setq doit (start_dialog)) (cond ((= doit 1) (do-array) ) ((= doit 3) (setq *point0* (getpoint "\nPick a point: ")) ) ) ;_ end of cond ) ;_ end of while (unload_dialog ad_id) ) ;_ end-of adarray (defun init-array () (setq blks (vla-get-blocks *thisdrawing*) num (vla-get-Count blks) *blknames* nil i 1 ) ;_ end of setq (repeat (- num 2) (setq blk (vla-item blks (setq i (1+ i))) bname (vla-get-Name blk) *blknames* (append *blknames* (list bname)) ) ;_ end of setq ) ;_ end of repeat (if *blknames* (progn (start_list "bname") (mapcar 'add_list *blknames*) (end_list) ) ;_ end of progn ) ;_ end of if (if bnameindex (set_tile "bname" (itoa bnameindex)) ) ;_ end of if (if *rowdist* (set_tile "row" (rtos *rowdist*)) (set_tile "row" "2") ) ;_ end of if (if *coldist* (set_tile "col" (rtos *coldist*)) (set_tile "col" "2") ) ;_ end of if ) ;_ end of init-array (defun get-adarray-data () (setq bnameindex (atoi (get_tile "bname"))) (setq *bname* (nth bnameindex *blknames*)) (setq *rowdist* (atoi (get_tile "row"))) (setq *coldist* (atoi (get_tile "col"))) ) ;_ end-of get-tool-data (defun do-array () (setq lyr "arr-hatch") (vl-cmdf "Layer" "M" lyr "C" "green" "" "") (vl-cmdf "-Hatch" *point0* "P" "U" "0.0" *rowdist* "N" "") (vl-cmdf "Explode" (entlast)) (setq ss (ssget "X" (list '(0 . "LINE") (cons 8 lyr) ) ;_ end of list ) ;_ end of ssget num (sslength ss) i -1 ) ;_ end of setq (rsetv "CLAYER") (repeat num (setq en (ssname ss (setq i (1+ i)))) (vl-cmdf "Measure" en "B" *bname* "Y" *coldist*) (entdel en) ) ;_ end of repeat ) ;_ end of do-array (defun c:ad () (setting) (adarray) (resetting) (princ) ) ;_ end of c:ad (prompt "\nCopyright (c) 2007, Tony Hotchkiss") (prompt "\nEnter AD to start") i cant use this lisp in autocad. ADARRAY - Error: Quit / exit abort System variable have benn reser Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.