Jump to content

Tough Questions - OSNAP Lisp


Recommended Posts

Posted

Tough Questions - OSNAP Lisp

 

 

AutoCAD 2007

I have a quite a few tough questions/requests and I am currently looking for some lisps to solve them. I have been doing some searching online to find the lisps I need, and although I have been able to find some stuff, I still have some things that I can't seem to find exactly what I am looking for. I would like to take the opportunity ahead of time to thank every who views my questions and for any help that is given.

 

 

When using lisps I am finding that many of them reset my OSNAP settings, I was wondering if there was a way or a lisp that can be used to keep my OSNAP setting. So far the only thing I have found is the variable "OSMODE" which has a numerical setting based on the snaps set.

Posted

The fact that they reset your osnaps is merely that the LISP is badly written, not the downside of LISP itself.

Posted
The fact that they reset your osnaps is merely that the LISP is badly written, not the downside of LISP itself.

 

Thanks Lee. I was going to post something very similar. Good programmers will reset any variables or settings that are changed for the sake of the functionality of the LISP routine.

Posted

I agree with Lee, however if it's a bug in autocad, not lisp, we noticed something similar with the auto savetime settings, so I've modified this lisp we found to work for osnap settings, see what you think. Set the value of the red highlight to the osnap setting you usually use:

 

(not tested & not recommended)

 

(defun C:ALERTME ()
(vl-load-com)
(setq VTFRXN (vlr-editor-reactor nil '((:VLR-sysVarChanged . VTF))))
)

(defun VTF (CALL CALLBACK / str val)
(setq val [color=Red]39[/color])
(if (and
(= (strcase (car CALLBACK)) (setq str "OSMODE"))
(eq (getvar str) 0)
)
(progn
(princ (strcat "Warning: Someone or something has changed your " str " settings.\n" str " has been changed back to " (itoa val)))
(setvar str val)
)
)
)
(c:alertme)

Posted

Nice one Steve,

 

I would include a function like this to remove reactor also though!

 

(defun c:rem_reac ( )
 (and VTFRXN (vlr-remove VTFRXN))
 (setq VTFRXN nil)
 (princ))

Posted

True, good thing to add. I didn't write it, someone at work found it (hopefully they didn't remove a copyright)

 

John, it's not recommended because it could conflict if you have lisps that modify the OSMODE settings.

Posted

Many routines start off by SAVING your current OSMODE setting prior to changing it then resetting it back after the routine completes.

Just make sure your error trapping does the same if the routine is cancelled.

 

If you're trying to learn (like me!) Post the problem routine and the code masters

will not only show you how to fix it, you'll learn what to look for in bad coding as well!!

Posted

I've found the reactors for resetting the osmode to be quite annoying and it's not that difficult to code your *error* sub to reset everything accordingly.

 

For example:

(defun c:TEst (/ *error* #Osmode #Pnt1 #Pnt2)
;;; error handler
 (defun *error* (#Message)
   (and #Osmode (setvar 'osmode #Osmode))
   (and #Message
        (not (wcmatch (strcase #Message) "*BREAK*,*CANCEL*,*QUIT*"))
        (princ (strcat "\nError: " #Message))
   ) ;_ and
 ) ;_ defun

 (setq #Osmode (getvar 'osmode))
 (setvar 'osmode 4105)
 (and (setq #Pnt1 (getpoint "\nSpecify first point: "))
      (setq #Pnt2 (getpoint #Pnt1 "\nSpecity next point: "))
      (command "_.line" "_non" #Pnt1 "_non" #Pnt2 "")
 ) ;_ and
 (and #Osmode (setvar 'osmode #Osmode))
 ;; or you can type: (*error* nil)
 (princ)
) ;_ defun

Posted

Hey guys, thank you for taking the time to work on answering my problems. I usually try to reply with at least a thank you or my results, but I never seem to think that people come back to my question to ever see my thank you reply. You are right though, and I apologize. I will give these answers a try. Thanks again.

Posted

Thanks for the reply John. No we always want to know how it goes otherwise how will we ever improve! :)

 

And yeah I agree with Alan and "Ilovemadoka", best to post or fix your lisps that are resetting OSNAP.

Posted
Thanks for the reply John. No we always want to know how it goes otherwise how will we ever improve! :)

 

And yeah I agree with Alan and "Ilovemadoka", best to post or fix your lisps that are resetting OSNAP.

What else have we got to live for? :(

Posted
What else have we got to live for? :(

Waiting for your wife. (I lost count how many times you've written code while waiting for something :lol:)

Posted
Waiting for your wife. (I lost count how many times you've written code while waiting for something :lol:)

 

LoL

How very true. Idle hands are the devil's playground.

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