Perfect!Thanks to everyone that helped me on this one! I found this to work for getting you preset osnap variables and restoring them back after the program is finished.
Put this first inside the lisp program
(setq osn (getvar "osmode"))
Put this last inside the lisp program
(command "osmode" osn)
In writing various LISP routines I always want to turn the Osnaps off and then reset them to whatever the user had them set at previously. To capture the initial settings I use something like:
(setq old_mode (getvar "osmode") )
(setvar "osmode" 0)
This captures the current setting into the variable old_mode and then turns all of the Osnap settings off.
To return to the initial Osnap state I would use:
(setvar "osmode" old_mode) Yeah, I do too. I was just copying a piece of code as an option to the original question. Here's what I pasted from:
(defun c:2at ()
(defun dtr (a)
(* pi(/ a 180.0))
)
(command "layer" "S" "fan" "")
(command "orthomode" "1")
(setq osn (getvar "osmode"))
(command "osnap" "center")
(setq pick (getpoint "\Select isolator hole on base: "))
(setq rot1 (polar pick (dtr 0.0) 0.6))
(command "osmode" "0")
(command "insert" "2a-isolatortop=" pick "" "" "")
(command "insert" "2a-isoplatetop=" pick "" "" "")
(command "rotate" "c" pick rot1 "l" "" pick pause)
(command "osmode" osn)
(command "layer" "S" "casing" ""))
It's an isolator top view that places them on A/C fans. i use this:
(defun c:AS ( / )(setvar 'osmode 105)(princ "\nActive Osnaps: End, Insertion, Intersection, & Node")(princ));defuni can run it real quick to set my desired snaps, or i can run it transparently (typing: 'as) Good idea for a stand alone machine.
The only problem I can see with setting a specific snap, is in the case of sharing a server with AutoCAD & the programs. Each individual person, as you probably already know, have their own settings and style they prefer. The getvar osmode grabs each persons settings and holds on to it until it completes the function of the program, then resetting it back to each individual persons settings with the "osmode" re-call.
That is my problem; we have a command (which i cannot edit) which sets my OSnap settings to Nearest. I edited my CUI file so that Shift + Button 3 will set my Osnap to 4263. The problem is that I want to do this whilst the "faulty" command is running, not after. Thanks.
Hello everyone BTW
yawdapaah, the string (setvar "osmode" 4263)(princ) will set the osnaps while in a command,you can make a tollbar button to reset the settings while in a command, or a keyboard shortcut yawdapaah,
How is this command or program that your talking about, initiated? From a Toolbar button located in the CUI? Shortcut keys? Command prompt from your appload? Just curious.......... Also something to think about: What is the first command you use right after this program has ran it's course.
页:
1
[2]