Jump to content

Recommended Posts

Posted

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.

Posted

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

Posted

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

Posted

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 :P

Posted
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 :P

Posted

Maybe

(- 1 (getvar "SNAPMODE"))

-David

Posted
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. :thumbsup:

Posted

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

Posted

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.

Posted

thanks for all the replies, got it working

Posted

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

Posted

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

Posted

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

Posted

Ahh, thanks for the help VVA, I understand it now.

 

Cheers

 

Lee

  • 13 years later...
Posted
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 :P

 

 

This really works for me ! Thank you very much! 

Posted
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!

  • Like 1
Posted
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. 

  • Like 2

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