osmode help

Discussion in 'AutoCAD' started by Stephen H., Aug 20, 2004.

  1. Stephen H.

    Stephen H. Guest

    How do I capture the current osmode setting within a lisp routine and then set that osmode back when the routine is over.
     
    Stephen H., Aug 20, 2004
    #1
  2. Stephen H.

    Jürg Menzi Guest

    Hi Stephen

    The following program fragment shows how to handle this. If you pauses for
    user input inside your code, I would propose to use an error handle to reset
    the previous sysvar status in case of pressing the ESC key.
    Code:
    (defun C:MyProgram ( / OldOsm *error*)
    (setq OldOsm (getvar "OSMODE"))
    
    ;-- Establish error handler
    (defun *error* (Msg)
    (setvar "OSMODE" OldOsm)
    (if Msg (princ Msg))
    (princ)
    )
    
    ;-- Here comes your code
    (...)
    
    ;-- Reset Systemvars
    (*Error* nil)
    )
    
    Cheers
     
    Jürg Menzi, Aug 20, 2004
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.