How to snap to visible Grid points?

Hi,

I would like to use the "snap to grid" option in a way, that the cursor snaps to visible grid points shown in the various zoom states. I.e. in the picture below, I would like to snap it to the cyan points if the upper zoom level is apllied, when zooming further in, I would like to snap it to the magenta points.

I assumed, that the adaptive grid setting would provide this, but unfortunately, this was not working. When I turned it on, I there was no snap at all.

Comments

  • Yes, directly linking grid and snap would be much more intuitive than the current behavior.
    It used to be like that, before adaptive grid/snap was introduced, as long as GRIDUNITS were set to 0,0 - but disabling the adaptive mode is probably not an option for you.

    However, if snapping to minor / major grid lines is sometimes more important to you than adaptive snapping, you could temporarily disable it, set the gridspacing (GRIDUNIT and GRIDMAJOR) to your liking, and then use code like this to switch between snapping to minor or major lines:

    (defun switch_gridsnap ( / ) (if (not (member 0 (getvar "GRIDUNIT"))) (if (equal (getvar "SNAPUNIT") (getvar "GRIDUNIT")) (setvar "SNAPUNIT" (mapcar '* (getvar "GRIDUNIT") (list (getvar "GRIDMAJOR") (getvar "GRIDMAJOR")))) (setvar "SNAPUNIT" (getvar "GRIDUNIT")) ) (princ "Grid units may not be zero") ) (princ) )

    Making this useful would imply loading this code automatically (using APPLOAD, putting it in on_doc_load.lsp, an .mnl file...) and creating a shortcut, e.g. like in the attached screenshot.

    Of course, that would merely be a workaround, the behavior you expected is worth a feature request.

  • Someone marked this as answered... but the proposed workaround was not very satisfactory.
    I rewrote the script a bit, so that it also makes sense for my own needs.

    It now cycles through three states:
    1.) Adaptive grid and snap spacing - as mentioned before, the two are not synchronized.
    2.) Fixed grid with snapping to minor grid lines.
    3.) Fixed grid with snapping to major grid lines.

    Lisp file is attached, in case this is of interest to someone.

  • Oops, stumbled over an error - corrected file attached.