chelsea1307 Posted January 16, 2009 Posted January 16, 2009 Does anyone have a code or can pull a section out of a code that will turn all osnaps off, and one that will turn the osnaps back on. I want to place it at the beginning and end of a code I already have and osnaps cause problems while running the code, any help would be great. Quote
Lee Mac Posted January 16, 2009 Posted January 16, 2009 A nice example from CAB: (defun Set_osmode (flg) ; nil=OFF t=ON (if (or (and flg (>= (getvar "osmode") 16383)) ; ON & osmode is off (and (null flg) (<= (getvar "osmode") 16383)) ; OFF & osmode is ON ) (setvar "osmode" (boole 6 (getvar "osmode") 16384)) ; Toggle osmode ) ) Quote
MaxwellEdison Posted January 16, 2009 Posted January 16, 2009 I'm sure you could probably get it to revert to the current state as opposed to just turning all on...LEE!!! Get in here!!! *EDIT* Jeez, he's faster than I thought... Quote
Lee Mac Posted January 16, 2009 Posted January 16, 2009 Well, I just normally do this: (setq oldsnap (getvar "osmode")) (setvar "osmode" 0) [b][color=Red] your code[/color][/b] (setvar "osmode" oldsnap) But I don't suppose this is very professional Quote
Lee Mac Posted January 16, 2009 Posted January 16, 2009 I'm sure you could probably get it to revert to the current state as opposed to just turning all on...LEE!!! Get in here!!! *EDIT* Jeez, he's faster than I thought... Haha, you posted only a minute after I did Quote
David Bethel Posted January 16, 2009 Posted January 16, 2009 Maybe (- 1 (getvar "SNAPMODE")) -David Quote
Lee Mac Posted January 16, 2009 Posted January 16, 2009 Maybe(- 1 (getvar "SNAPMODE")) -David I suppose I should use this also, instead off using the actual Osnap settings - just turn the option itself on and off. Nice code David. Quote
David Bethel Posted January 16, 2009 Posted January 16, 2009 Lee, Remember that this just toggles the current setting without checking what that setting is. I like it more for menu type usage $(if,$(=,$(getvar,SNAPMODE),1),!.)Toggle SNAPMODE]^c^c^p(setvar "SNAPMODE" (- 1 (getvar "SNAPMODE")));^p -David Quote
Lee Mac Posted January 16, 2009 Posted January 16, 2009 I see what you mean - but with some routines, I might just turn the OSnaps off so as not to interefere with anything, so I don't mind what the setting is, as long as it is off. Quote
chelsea1307 Posted January 16, 2009 Author Posted January 16, 2009 thanks for all the replies, got it working Quote
Lee Mac Posted January 16, 2009 Posted January 16, 2009 Who'd have thought you'd get such a lot of replies in such a small amount of time... Glad you got it working Chels Quote
VVA Posted January 16, 2009 Posted January 16, 2009 My Old version of functions (defun disable_osmode () ;;; turn osnaps off (if (and (< (getvar "OSMODE") 16000) (/= (getvar "OSMODE") 0) ) (setvar "OSMODE" (+ (getvar "OSMODE") 16384)) )) (defun enable_osmode () ;;; turn osnaps on (if (> (getvar "OSMODE") 16000) (setvar "OSMODE" (- (getvar "OSMODE") 16384)) ) ;_if ) My new version (defun disable_osmode () ;;; turn osnaps off (setvar "osmode" (logior (getvar "OSMODE") 16384)) ) (defun enable_osmode () ;;; turn osnaps on (setvar "osmode"(boole 2 (getvar "OSMODE") 16384)) ) Quote
Lee Mac Posted January 16, 2009 Posted January 16, 2009 What is the significance of 16384 and 16000? Quote
VVA Posted January 17, 2009 Posted January 17, 2009 From the help OSMODE System Variable Type: Integer Saved in: Registry Initial value: 4133 Sets running object snaps. The setting is stored as a bitcode using the sum of the following values: 0 - NONe 1 - ENDpoint 2 - MIDpoint 4 - CENter 8 - NODe ... 4096 - EXTension 8192 - PARallel To specify more than one object snap, enter the sum of their values. For example, entering 3 specifies the Endpoint (bitcode 1) and Midpoint (bitcode 2) object snaps. Entering 16383 specifies all object snaps. When object snaps are switched off using the Osnap button on the status bar, a bitcode of 16384 (0x4000) is returned, in addition to the normal value of OSMODE. With this additional value, developers can distinguish this mode from Object Snap modes that have been turned off from within the Drafting Settings dialog box. Setting this bit toggles running object snaps off. Setting OSMODE to a value with this bit off toggles running object snaps on. More correctly not 16000 and 16384 For example 1. Set OSMODE=1 2. The press F3 (turn osnaps off) 3. Type OSMODE in command line and you will see value 16385 (16384 + 1) Repeat point 1-3 with OSMODE=3, 7, 15 and so on. To turn off a osnap it is necessary to add to value OSMODE 16384 To turn on a osnap it is necessary to subtract from value OSMODE 16384 With corresponding checks Quote
Lee Mac Posted January 17, 2009 Posted January 17, 2009 Ahh, thanks for the help VVA, I understand it now. Cheers Lee Quote
PKR Posted November 1, 2022 Posted November 1, 2022 On 1/16/2009 at 10:12 AM, Lee Mac said: Well, I just normally do this: (setq oldsnap (getvar "osmode")) (setvar "osmode" 0) [b][color=Red] your code[/color][/b] (setvar "osmode" oldsnap) But I don't suppose this is very professional This really works for me ! Thank you very much! Quote
tombu Posted November 2, 2022 Posted November 2, 2022 20 hours ago, PKR said: This really works for me ! Thank you very much! It turns all of them off if that's what you want, but Lee Mac's first post "A nice example from CAB:" toggles the osnaps on & off. You can also do this by clicking the "2D Object Snap" icon on the Status Bar or using either F3 or Ctrl+F. Welcome to our Forums! 1 Quote
resullins Posted November 2, 2022 Posted November 2, 2022 On 1/16/2009 at 10:10 AM, MaxwellEdison said: I'm sure you could probably get it to revert to the current state as opposed to just turning all on...LEE!!! Get in here!!! *EDIT* Jeez, he's faster than I thought... I love both the way you automatically summon him as the keeper of this answer AND the fact that he beat you to it. He's like the CAD genie. 2 Quote
Recommended Posts
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.