STG LISP: Snap Text to Nearest Grid Point (Free AutoLISP Download)
STG snaps the insertion point of selected TEXT entities (typically elevation labels) onto the nearest point of a regular grid, defined by a chosen grid spacing. Many downstream survey/GIS/terrain-modeling programs expect point data to sit exactly on regular grid coordinates, this routine cleans up scattered or imprecisely placed text so it conforms.
SNAPGRID-bgol (Snap Text to Nearest Grid Point)
Command Type: AutoLISP routine (works in AutoCAD, BricsCAD, ZWCAD and most AutoLISP-compatible CAD platforms)
Developed by: BGol Community, bgol.in
Inspired by the general concept of grid-snapping utilities used in survey and GIS drafting. This is an original, independently written routine, new file name, new command name, new source code, created so the CAD community has a free, editable, open-source alternative.
Overview
STG snaps the insertion point of selected TEXT entities (typically elevation labels) onto the nearest point of a regular grid, defined by a chosen grid spacing. Many downstream survey/GIS/terrain-modeling programs expect point data to sit exactly on regular grid coordinates, this routine cleans up scattered or imprecisely placed text so it conforms.
How to Use
- Load
SNAPGRID-bgol.lspinto your CAD session (drag-and-drop the file onto the drawing window, or use theAPPLOADcommand). - Type
STGat the command line and press Enter. - Select one or more TEXT entities whose insertion points are scattered/off-grid.
- Enter the grid spacing (e.g.
5). - Each selected text's insertion point is moved to the nearest grid intersection (X and Y each rounded to the nearest multiple of the spacing), and a small marker circle is drawn at the new point on layer
BGOL-STGfor visual confirmation.
Why Use It
- Meets strict grid requirements, ensures point/elevation data conforms to the grid-coordinate requirements of downstream terrain, GIS, or modeling software, avoiding rejected or misinterpreted imports.
- Cleans up scattered labels, turns visually scattered or inconsistently placed text into a neat, regular grid layout in one operation across many texts at once.
- No manual calculation, removes the need to manually calculate and re-enter each text's snapped coordinate by hand.
Where to Use It
- Preparing elevation/point data exports for grid-based terrain, GIS, or modeling software that requires strictly gridded input.
- Cleaning up manually digitized or imported drawings where text labels ended up slightly off the intended regular grid.
- Any drafting QA step ensuring elevation label positions are grid-consistent before further processing or export.
Notes
- Rounding uses standard round-half-up logic on both X and Y independently (e.g. a text at X=23.45, Y=34.56 with a grid value of 5 snaps to (25, 35)).
- The text's Z (elevation) value, string content, height, and style are left unchanged, only the X/Y insertion point is modified.
- A confirmation marker circle is placed at each new snapped location on
BGOL-STGso you can quickly verify the result visually. - Source code is fully open, feel free to study, modify, and redistribute it under the same open, free-for-all spirit.
Credits
Developed and shared for the CAD community by BGol Community. Website: https://bgol.in/ Free and open-source, use it, modify it, share it, for personal or commercial work alike.
Frequently Asked Questions
STG is a standard AutoLISP routine, so it runs in AutoCAD, BricsCAD, ZWCAD, and most other AutoLISP-compatible CAD platforms without modification.
Rounding uses standard round-half-up logic on both X and Y independently (e.g. a text at X=23.45, Y=34.56 with a grid value of 5 snaps to (25, 35)).
Meets strict grid requirements, ensures point/elevation data conforms to the grid-coordinate requirements of downstream terrain, GIS, or modeling software, avoiding rejected or misinterpreted imports.
Yes. STG is fully open-source and free to use, modify, and redistribute for both personal and commercial work, developed and shared by the BGol Community.
Drag and drop SNAPGRID-bgol.lsp onto your open drawing window, or load it through the APPLOAD command, then type STG at the command line to run it.
🤝 About BGol Community
BGol Community of Advanced Surveying builds and shares free, open-source tools for the survey and CAD drafting community.
🙌 Made with ❤️ by BGol Community of Advanced Surveying
Free, open-source, and built for the CAD community, for personal or commercial use, always.