Dayananda Posted November 29, 2019 Posted November 29, 2019 What is the system variable for Polar on off to use with lisp. ( F10) Quote
Emmanuel Delay Posted November 29, 2019 Posted November 29, 2019 I think this answers it https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/polar-tracking/td-p/2570439 1 Quote
Lee Mac Posted November 29, 2019 Posted November 29, 2019 (edited) 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 November 29, 2019 by Lee Mac 1 1 Quote
BIGAL Posted November 30, 2019 Posted November 30, 2019 (edited) 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 December 2, 2019 by BIGAL Quote
Lee Mac Posted November 30, 2019 Posted November 30, 2019 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? Quote
BIGAL Posted December 2, 2019 Posted December 2, 2019 (edited) 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 December 2, 2019 by BIGAL 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.