Jump to content

Polar on off system variable.


Dayananda

Recommended Posts

The system variable that you require for this task is AUTOSNAP.

 

This system variable is bit-coded, with the following bit codes exhibiting the associated behaviour as described below:

  • 0    Turns off the AutoSnap marker, tooltips, and magnet. Also turns off polar tracking, object snap tracking, and tooltips for polar tracking, object snap tracking, and Ortho mode
  • 1    Turns on the AutoSnap marker
  • 2    Turns on the AutoSnap tooltips
  • 4    Turns on the AutoSnap magnet
  • 8    Turns on polar tracking
  • 16    Turns on object snap tracking
  • 32    Turns on tooltips for polar tracking, object snap tracking, and Ortho mode

As such, to control Polar tracking, you'll need to flip bit 8.

 

Since we're working with a bit-coded integer, it is easiest & most appropriate to manipulate this value using the various bitwise functions defined in AutoLISP: boole, logand, logior, ~. Below are a few examples demonstrating how to accomplish this:

 

Turn on Polar Tracking:

(setvar 'autosnap (logior 8 (getvar 'autosnap)))

Note that the above is still applicable even when polar tracking is already turned on, since logior implements inclusive OR logic (hence the name "ior"):

_$ (logior 8 39)
47
_$ (logior 8 47)
47

Check if Polar Tracking is enabled:

_$ (= 8 (logand 8 (getvar 'autosnap)))
T

Turn off Polar Tracking:

(setvar 'autosnap (logand (~ 8) (getvar 'autosnap)))

Note that the above is performing a bitwise AND against the 1's-complement of 8 which is 31-bits set to 1 with bit 8 set to 0, that is, returning all bits except bit 8:

_$ (int->bin (~ 8))
"11111111111111111111111111110111"
11111111111111111111111111110111 = (~ 8) = -9
00000000000000000000000000101111 = 47
---------------------------------- LOGAND
00000000000000000000000000100111 = 39

Check if Polar Tracking is disabled:

_$ (zerop (logand 8 (getvar 'autosnap)))
T

Toggle Polar Tracking:

_$ (setvar 'autosnap (boole 6 8 (getvar 'autosnap)))
47
_$ (setvar 'autosnap (boole 6 8 (getvar 'autosnap)))
39

Here, supplying the first argument of 6 to the boole function results in bitwise XOR logic (exclusive OR):

00000000000000000000000000001000 =  8
00000000000000000000000000101111 = 47
---------------------------------- XOR
00000000000000000000000000100111 = 39
00000000000000000000000000001000 =  8
00000000000000000000000000100111 = 39
---------------------------------- XOR
00000000000000000000000000101111 = 47

 

Edited by Lee Mac
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Checked in Autocad was 39 Briscad 119 so quick and dirty write down the numbers required after running lee's code.

 

(setvar 'autosnap 47)

(setvar 'autosnap 39)

 

 

Edited by BIGAL
Link to comment
Share on other sites

4 hours ago, BIGAL said:

Checked in Autocad was 39 Briscad 119 so quick and dirty write down the numbers required after running lee's code. 119 is odd ?

 

(setvar 'autosnap 47)

(setvar 'autosnap 39)

Does not work in Briscad

 

Sorry, I've re-read this several times over, but I still don't know what you are trying to say here?

 

Link to comment
Share on other sites

Sorry Lee. changed post for clarity, thanks Steven-g

 

When I tried the above code in Briscad the other day it did not work, today it did including 64 check it showed no 8 to be set. Just one of those things, why did it not work the other day ? Not something I would use so did not look further into it.

 

There are some minor Autocad-Briscad code problems, but not many.

 

Edited by BIGAL
Link to comment
Share on other sites

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