<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Toggle &amp;quot;Nearest&amp;quot; OSNAP Option in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/toggle-quot-nearest-quot-osnap-option/m-p/12380946#M21711</link>
    <description>&lt;P&gt;hey,&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;(defun c:nn ()
	(setvar 'osmode 512)
)&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 16 Nov 2023 08:31:34 GMT</pubDate>
    <dc:creator>komondormrex</dc:creator>
    <dc:date>2023-11-16T08:31:34Z</dc:date>
    <item>
      <title>Toggle "Nearest" OSNAP Option</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/toggle-quot-nearest-quot-osnap-option/m-p/12380891#M21710</link>
      <description>&lt;P&gt;Hi, I need a script that toggles the nearest option in the OSNAP settings using the shortcut "nn."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2023 07:53:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/toggle-quot-nearest-quot-osnap-option/m-p/12380891#M21710</guid>
      <dc:creator>Temssi.d</dc:creator>
      <dc:date>2023-11-16T07:53:48Z</dc:date>
    </item>
    <item>
      <title>Re: Toggle "Nearest" OSNAP Option</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/toggle-quot-nearest-quot-osnap-option/m-p/12380946#M21711</link>
      <description>&lt;P&gt;hey,&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;(defun c:nn ()
	(setvar 'osmode 512)
)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 16 Nov 2023 08:31:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/toggle-quot-nearest-quot-osnap-option/m-p/12380946#M21711</guid>
      <dc:creator>komondormrex</dc:creator>
      <dc:date>2023-11-16T08:31:34Z</dc:date>
    </item>
    <item>
      <title>Re: Toggle "Nearest" OSNAP Option</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/toggle-quot-nearest-quot-osnap-option/m-p/12381159#M21712</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Almost there; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;my explanation might not have been clear. What I'm looking for is that, upon clicking, the entire configuration remains unchanged, except for toggling the "nearest" option – turning it on if it's off and vice versa.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2023 10:28:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/toggle-quot-nearest-quot-osnap-option/m-p/12381159#M21712</guid>
      <dc:creator>Temssi.d</dc:creator>
      <dc:date>2023-11-16T10:28:17Z</dc:date>
    </item>
    <item>
      <title>Re: Toggle "Nearest" OSNAP Option</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/toggle-quot-nearest-quot-osnap-option/m-p/12381203#M21713</link>
      <description>&lt;P&gt;Try&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;(defun c:nn nil
  (if (= 512 (logand 512 (getvar 'OSMODE)))
    (setvar 'OSMODE (- (getvar 'OSMODE) 512))
    (setvar 'OSMODE (+ (getvar 'OSMODE) 512))
  )
  (princ)
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps, &lt;BR /&gt;Henrique&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2023 10:56:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/toggle-quot-nearest-quot-osnap-option/m-p/12381203#M21713</guid>
      <dc:creator>hmsilva</dc:creator>
      <dc:date>2023-11-16T10:56:05Z</dc:date>
    </item>
    <item>
      <title>Re: Toggle "Nearest" OSNAP Option</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/toggle-quot-nearest-quot-osnap-option/m-p/12381280#M21714</link>
      <description>&lt;P&gt;one more&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;(defun c:nn (/ _osmode)
	(if (zerop (logand (lsh (setq _osmode (getvar 'osmode)) -9) 1))
		(setvar 'osmode (logior _osmode 512))
		(setvar 'osmode (logand _osmode 261631))
	)
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2023 11:46:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/toggle-quot-nearest-quot-osnap-option/m-p/12381280#M21714</guid>
      <dc:creator>komondormrex</dc:creator>
      <dc:date>2023-11-16T11:46:12Z</dc:date>
    </item>
    <item>
      <title>Re: Toggle "Nearest" OSNAP Option</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/toggle-quot-nearest-quot-osnap-option/m-p/12381288#M21715</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;You can do a bitwise 'XOR'.&lt;/P&gt;
&lt;LI-CODE lang="lisp"&gt;(defun c:nn ()
  (setvar 'osmode (boole 6 512 (getvar 'osmode)))
  (princ)
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2023 11:48:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/toggle-quot-nearest-quot-osnap-option/m-p/12381288#M21715</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2023-11-16T11:48:21Z</dc:date>
    </item>
    <item>
      <title>Re: Toggle "Nearest" OSNAP Option</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/toggle-quot-nearest-quot-osnap-option/m-p/12381334#M21716</link>
      <description>&lt;P&gt;Using this sort of toggle for years... and ended up with this macro assigned to the Fx key. A macro, because it simply behaves better than lisp.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;'_.osmode $M=$(+,$(getvar,osmode),$(if,$(and,$(getvar,osmode),512),$(if,$(and,$(getvar,osmode),16384),-16384,-512),$(if,$(and,$(getvar,osmode),16384),-15872,512)))&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2023 12:12:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/toggle-quot-nearest-quot-osnap-option/m-p/12381334#M21716</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2023-11-16T12:12:30Z</dc:date>
    </item>
    <item>
      <title>Re: Toggle "Nearest" OSNAP Option</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/toggle-quot-nearest-quot-osnap-option/m-p/12381424#M21717</link>
      <description>huge thanks!&lt;BR /&gt;</description>
      <pubDate>Thu, 16 Nov 2023 12:50:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/toggle-quot-nearest-quot-osnap-option/m-p/12381424#M21717</guid>
      <dc:creator>Temssi.d</dc:creator>
      <dc:date>2023-11-16T12:50:46Z</dc:date>
    </item>
    <item>
      <title>Re: Toggle "Nearest" OSNAP Option</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/toggle-quot-nearest-quot-osnap-option/m-p/12382541#M21718</link>
      <description>&lt;P&gt;Some of those code offerings are a bit confusing so, in addition (and to get a chance to play around a bit too) I thought I'd offer up some other solutions that do not bother checking if this/that is on/off (you can pretty much just rely on AND, OR, or XOR to do that for you:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To make sure snaps are on, you can just do a logand on the 14th bit.&lt;BR /&gt;(setvar 'OSMODE (logand (getvar 'OSMODE) -16385))&lt;BR /&gt;; -16385 is the 14th bit cleared (aka: (~ 16384))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To toggle snaps on/off, you can just do an XOR on the 14th bit.&lt;BR /&gt;(setvar 'OSMODE (boole 6 (getvar 'OSMODE) 16384))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To turn on the osnaps and turn off the nearest snap, you can clear both bits with logand.&lt;BR /&gt;(setvar 'OSMODE (logand (getvar 'OSMODE) (+ (1+ (~ 16384)) (~ 512))))&lt;BR /&gt;; (1+ (~ 16384)) is -16484&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To turn off the osnaps and turn on the nearest snap, you can clear one bit and flip the other with OR.&lt;BR /&gt;(setvar 'OSMODE (logior (getvar 'OSMODE) (+ 16384 512)))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To just toggle both bits and hope for the best (use XOR).&lt;BR /&gt;(setvar 'OSMODE (boole 6 (getvar 'OSMODE) (+ 16384 512)))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Finaly, to turn snaps on and toggle the nearest bit on/off (use AND &amp;amp; XOR).&lt;BR /&gt;(setvar 'OSMODE (logand (boole 6 512 (getvar 'OSMODE)) -16385))&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2023 20:43:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/toggle-quot-nearest-quot-osnap-option/m-p/12382541#M21718</guid>
      <dc:creator>john.kaulB9QW2</dc:creator>
      <dc:date>2023-11-16T20:43:49Z</dc:date>
    </item>
    <item>
      <title>Re: Toggle "Nearest" OSNAP Option</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/toggle-quot-nearest-quot-osnap-option/m-p/12383235#M21719</link>
      <description>&lt;P&gt;In some commands you can do transparent osnap resets, Line is an example if you have made defuns say for various osnap settings these just (setvar 'osmode 47) in this case I made a (defun c:47 ()(setvar 'osmode 47))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In say "LINE" then type '47 the apostrophe is call transparent command '00 would be say (setvar 'osmode 0) for all off, same as F3.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2023 05:17:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/toggle-quot-nearest-quot-osnap-option/m-p/12383235#M21719</guid>
      <dc:creator>Sea-Haven</dc:creator>
      <dc:date>2023-11-17T05:17:19Z</dc:date>
    </item>
  </channel>
</rss>

