Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/29/2019 in all areas

  1. Unfortunately the update to the forum software implemented several months back caused BBCode formatting tags embedded within code to become visible in code blocks, and also removed every instance of "8)" within code, breaking thousands of programs which previously ran successfully. I've now updated my earlier posts to fix the code.
    1 point
  2. 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
    1 point
  3. I think this answers it https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/polar-tracking/td-p/2570439
    1 point
×
×
  • Create New...