AboutScott Cook Expertise I`ve been using AutoCAD since 1987 and programming AutoLISP nearly as long. I can answer questions about programming AutoCAD (except ARX) and production enhancement techniques. I cannot answer questions about AutoCAD crashes or DWG corruption. AutoCAD PROGRAMMING (menus, lisp) related questions only!
Experience Since 1987. Author of Plot2000 software for for AutoCAD, http://www.plot2000.com.
PROGRAMMING QUESTIONS ONLY PLEASE. Questions that are NOT related to programming or AutoCAD customization (menus and lisp only please) are outside the scope of my volunteer services and will NOT BE ANSWERED.
I'm having problems with osnap. In my lisp script i would like to turn the osnap off and then turn it on but it must be the same as before, all functions must remain as before (example Endpoint, Circle...). Ok, i figured that out that i can help myself with osmode and number, but my script should be independent cause it will be used by many people, so i can't help myself with osmode. I'm wondering, is there maybe a way to run "F3" by script command (that just swiches osnap on and off)? Any other ideas maybe? Thank you in advance.
Answer this is done by saving the value of osmode at the beginning of your routine and restoring it at the end.
put this at the beginning of your routine, after the defun
(setq old-osmode (getvar "osmode"))
then before the end of your routine put this:
(setvar "osmode" old-osmode)
you will eventually need to read up on the *error* function which will allow you to do this even if someone presses cancel to get out of your routine.