• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
blog.draftsperson.net

blog.draftsperson.net

the art of technical drawing

blog.draftsperson.net

GRIDSNAP LISP: Pull Existing Geometry Onto a Grid

August 6, 2026

GRIDSNAP rounds the coordinates of things already drawn to the nearest multiple of a spacing you give. Snap mode only helps while you are drawing; this is for a drawing that has already gone astray — traced-over scans, imported DXF from a package with different tolerances, or work done with snap off where everything is a thousandth out and nothing quite meets.

What GridSnap does

Give it 1 and every coordinate becomes a whole number. Give it 25 and everything lands on a 25 mm grid.

How to use it

  1. Save the drawing first. This moves real geometry.
  2. Load the routine with APPLOAD, or put it on your support file search path.
  3. Type GRIDSNAP.
  4. Give the spacing and select the objects.
  5. Read the reported maximum shift. If it is bigger than you expected, U puts it all back in one step.

How it works

Rounding has to work either side of zero, and the obvious method does not. Taking the remainder and then either subtracting it or adding the difference, depending which half of the step it falls in, is right for positive coordinates and wrong for negative ones — because the remainder is negative there.

On a step of 5, a coordinate of −8 should go to −10. The naive version sends it to 0: two whole steps out, and in the wrong direction.

Rounding is done in one step instead — divide, add a half toward whichever side of zero the number is on, truncate, multiply back. That behaves the same on both sides.

Blocks have their insertion point edited directly rather than being moved with the MOVE command. That is both faster on a large selection and cannot be upset by a running object snap pulling the destination somewhere else.

Notes and limits

  • This moves real geometry. The largest distance anything shifted is reported at the end, and one U undoes the lot.
  • Lightweight polylines are handled — along with arcs, ellipses, MText, 3D faces and dimensions.
  • Negative coordinates round correctly.
  • One undo group covers the whole selection.

Download and details

NameGridSnap — round existing geometry onto a grid
DownloadGridSnap.lsp — 10.2 KB, plain AutoLISP source. Downloads directly; no zip to unpack.
TypeAutoCAD AutoLISP routine
CommandGRIDSNAP
Requiresnothing beyond a CAD platform with AutoLISP.
Source size10.2 KB, 243 lines
Error handlingYes — a *error* handler restores every system variable it changed, on cancel as well as on error.
UndoThe whole operation is wrapped in a single undo group, so one U reverses all of it.
CompatibilityAutoCAD (any release with AutoLISP), BricsCAD, ZWCAD, GstarCAD, ProgeCAD and other IntelliCAD-based platforms. AutoCAD LT needs a LISP enabler. No .NET, no ObjectARX, no installer.
AuthorYZ, August 2026
LicenceFree to use, supplied “as is” with no warranty.

References

  • STRAYHUNT LISP — find geometry at absurd coordinates first
  • VERTINJECT LISP — adding vertices while preserving width and bulge
  • BASESNAP LISP — justifying block base points
  • More free AutoLISP routines on this site
  • Wisey’s Steel Shapes — free structural steel section drawing program

Filed Under: AutoLISP Routines

Primary Sidebar

Subscribe to our Youtube Channel

Post CAD drafting jobs on Freelancer.com. and get some free money to do this.

Categories

  • American Steel Industry (4)
  • AutoCAD Articles & Reference (30)
  • AutoCAD Bugs & Problems (19)
  • AutoCAD Tips (29)
  • AutoCAD Tutorials (54)
  • AutoLISP Routines (328)
  • AutoLISP Tutorials (15)
  • CAD Standards (7)
  • Civil 3D (7)
  • Civil Drafting (4)
  • Dimensions (2)
  • Drafting Funnies (71)
  • Drafting History (9)
  • Drafting Standards (84)
  • Electrical Drafting (2)
  • General IT reference (7)
  • Geometry (15)
  • GIS (2)
  • Hatch Patterns (12)
  • Office Life Hacks (3)
  • PT (1)
  • Revit Tutorials (54)
  • Steel Detailing (14)
  • Structural Drafting (26)
  • Technical Dictionary (61)
  • Useful Website Links (19)

Footer

Free downloads

  • Free AutoLISP routines
  • Free hatch patterns
  • SHX fonts & text styles
  • Numbering LISP collection
  • ISO 3098B font

Reference charts

  • AWS weld symbols chart
  • Steel detailing chart
  • Hole & slot sizes
  • Bolt edge distance
  • ANSI & ARCH paper sizes
  • How to fold an A1 drawing

Useful links

  • CAD blocks (DWG)
  • Revit families
  • structuraldrafter.com
  • cad-corner.com
  • About
  • Privacy policy

Provided for free with no warranty · Log in