highflybird Posted January 20, 2014 Posted January 20, 2014 Hey guys, How to avoid the loss of Osnap ? Often use some lisp,later,Found Osnap lost Thanks for help! Quote
MSasu Posted January 20, 2014 Posted January 20, 2014 You need to have access to the AutoLISP code. The active Osnap modes were stored in OSMODE system variable; programmers will set it to 0 to don't interfere with draw operations performed by their code - however it should be restored when processing is done and also on error. (setq userOsm (getvar "OSMODE")) ;retain user setup (setvar "OSMODE" 0) ;disable temporary ... (setvar "OSMODE" userOsm) ;restore user setup Quote
flyfox1047 Posted January 21, 2014 Posted January 21, 2014 Try this: (defun resetosmode (v1 v2 /) (if (/= (getvar "osmode") 1015) (setvar "osmode" 1015) ) (princ) ) (vlr-editor-reactor nil '((:vlr-lispEnded . ResetOsmode) (:vlr-lispCancelled . ResetOsmode) (:vlr-commandEnded . ResetOsmode) (:vlr-commandCancelled . ResetOsmode) (:vlr-commandFailed . ResetOsmode) ) ) Quote
BIGAL Posted January 22, 2014 Posted January 22, 2014 Also look into error trap and put the reset osmode back to what it was, simplest way we have a 2 key reset for osmode and filedia. Quote
Jebus_kfc Posted January 22, 2014 Posted January 22, 2014 Try this: (defun resetosmode (v1 v2 /) (if (/= (getvar "osmode") 1015) (setvar "osmode" 1015) ) (princ) ) (vlr-editor-reactor nil '((:vlr-lispEnded . ResetOsmode) (:vlr-lispCancelled . ResetOsmode) (:vlr-commandEnded . ResetOsmode) (:vlr-commandCancelled . ResetOsmode) (:vlr-commandFailed . ResetOsmode) ) ) Flyfox1047 - How would I get this to work within an existing program? I have multiple programs that I would like to add some sort of error handling to so that when the user "Escapes" it doesn't cause them to loose all variables that have been changed for the program. Thanks in advanced! Quote
Jebus_kfc Posted January 22, 2014 Posted January 22, 2014 Thanks MSasu, I think I have finally figured it out! Quote
flyfox1047 Posted January 23, 2014 Posted January 23, 2014 Flyfox1047 - How would I get this to work within an existing program? I have multiple programs that I would like to add some sort of error handling to so that when the user "Escapes" it doesn't cause them to loose all variables that have been changed for the program. Thanks in advanced! Put it at the beginning of your code,or put it in acad20xxdoc.lsp Quote
MSasu Posted January 23, 2014 Posted January 23, 2014 Flyfox1047, please consider using the acad.lsp/acaddoc.lsp autoloaders instead of acad??.lsp/acad20??doc.lsp files; those were reserved for system purposes and appending to them isn't recommended (i.e. may be replaced by a repair or service pack installation). Quote
Jebus_kfc Posted January 23, 2014 Posted January 23, 2014 Thank you guys for your help. My original problem was if someone running my program were to esc. from the program, all toggled variables would be lost. So what I did was added the *error* code right after my getvar code. Also, within the *error* code, I reset all of the original variables. So now it works great!! I have been trying to figure this out for a couple of years now, and with your help now I have succeeded, thanks!!! 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.