Jump to content

Recommended Posts

Posted

Hey guys,

How to avoid the loss of Osnap ?

Often use some lisp,later,Found Osnap lost

Thanks for help!

Posted

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

Posted

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) 
  )
) 

Posted

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.

Posted
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!

Posted

Thanks MSasu, I think I have finally figured it out!

Posted
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

Posted

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).

Posted

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!!!

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...