rombi Posted September 2, 2019 Share Posted September 2, 2019 I've been trying to implement an error handler into the attached lisp, but i'm just too stupid to get it to work. I'm trying to get the lisp to reset the coordinate system (UCS) and Osnap setting to where they were before executing the program. If anyone could help me out with this, i would highly appreciate it. GEO9_RTOS_2dec.LSP Quote Link to comment Share on other sites More sharing options...
dlanorh Posted September 2, 2019 Share Posted September 2, 2019 (setq turesszog 1. textmeret 0.75) (setvar "cmdecho" 0) (command "layer" "ma" "geod_sajat" "c" "yellow" "" "u" "geod_sajat" "") (command "layer" "ma" "geodszov_sajat" "c" "magenta" "" "u" "geodszov_sajat" "") (if (not (tblsearch "ltype" "DASHDOT")) (command "linetype" "l" "DASHDOT" "DASHDOT.lin" "") );if (if (not (tblsearch "ltype" "center2")) (command "linetype" "l" "center2" "CENTER2.lin" "") );if (vl-load-com) (defun c:g ( / *error* sv_lst sv_vals );;put the rest of your local variables here (defun *error* (msg) (command-s "_ucs" "_R" "Cuser");restore entry ucs ;restore the entry ucs (command-s "_ucs" "_D" "lof");delete old ucs (mapcar 'setvar sv_lst sv_vals) ;restore sysvars to entry state (command-s "undo" "end") ) (setq sv_lst (list 'cmdecho 'osmode 'clayer 'celtype);; list of system variables to save (entry state) sv_vals (mapcar 'getvar sv_lst) ;; get the values of the above sysvars and store in a list ) (mapcar 'setvar sv_lst '(0 0) ;;sets cmdecho & osmode to 0 (zero) (command "_UCS" "_S" "Cuser");save the current ucs (if (tblsearch "ucs" "lof") (command "ucs" "d" "lof")) (graphscr) (setq xlist nil ylist nil marminusz 0) ;(setvar "cmdecho" 0) ;;this isn't needed here as it is set above ............ ............ ............ (command "_ucs" "_R" "Cuser");restore entry ucs (command "_ucs" "_D" "lof");delete old ucs (mapcar 'setvar sv_lst sv_vals) ;;restore sysvars to entry state (command "undo" "end") (princ) );defun The error routine should be inside the main routine and it should be listed in the local variables. Don't use command calls (command....) inside an error routine it will error from Autocad 2015. Use command-s instead. You will also need to reset at the end of the main routine. You can use command calls here. Quote Link to comment Share on other sites More sharing options...
rombi Posted September 3, 2019 Author Share Posted September 3, 2019 Thank you for taking the time. The program won't load after i applied these changes. I should have also mentioned this program was written 20 some years ago by someone Quote Link to comment Share on other sites More sharing options...
dlanorh Posted September 3, 2019 Share Posted September 3, 2019 (edited) 27 minutes ago, rombi said: Thank you for taking the time. The program won't load after i applied these changes. I should have also mentioned this program was written 20 some years ago by someone Any Error messages? Are you on Windows? Edited September 3, 2019 by dlanorh Quote Link to comment Share on other sites More sharing options...
BIGAL Posted September 4, 2019 Share Posted September 4, 2019 Try this wrapped all the defuns I am sure if this is wrong way some one will soon say so. May need (*error*) in each defun. GEO9_RTOS_2dec.LSP Quote Link to comment Share on other sites More sharing options...
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.