• 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

GRIDREF LISP: Survey Coordinate Grid Over a Viewport

August 6, 2026

GRIDREF lays a labelled Easting/Northing grid over whatever a layout viewport is showing: a border round the visible area, tick marks on the border at every grid interval with their coordinate written beside them, and a small cross at each grid intersection inside.

What GridRef does

This is what turns a site plan into a drawing someone can set out from. Without it a contractor has a picture; with it they have coordinates.

It draws in model space, not on the layout. The grid belongs to the site, so it moves with the model and shows through any viewport looking at that area.

How to use it

  1. Load the routine with APPLOAD, or put it on your support file search path.
  2. Set the viewport to show the area you want gridded, and lock it.
  3. Type GRIDREF.
  4. Pick the viewport.
  5. Give the grid interval, and the tick and text sizes at paper size.

How it works

The viewport carries everything needed. Its DXF data gives the paper-space width and height, the height of the model area it is showing, the centre of that area, and the twist angle. From those five numbers the scale is paper height over model height, and the visible model rectangle follows.

The standard group codes are read directly — 40 and 41 for the paper size, 45 for the model height, 12 for the view centre, 51 for the twist. Digging the same values out of the viewport’s extended entity data by counting along to fixed positions works until anything else attaches its own data to a viewport, and then it silently reads the wrong numbers.

Grid values are rounded outward to whole intervals, so a grid at 50 m lands on 1250, 1300, 1350 — never on 1263.4.

Each grid line is intersected against each of the four border edges, and an intersection falling within an edge gets a tick and a label. Doing it by intersection rather than by assuming which edge is which is what lets a twisted viewport work at all.

Sizes are given at paper size and divided by the viewport scale. So a grid over a 1:500 viewport and one over a 1:1000 viewport both plot with the same size ticks and text.

Notes and limits

  • Rotated viewports are handled, including labels flipped through 180° where they would otherwise print upside down.
  • Ticks point outward, away from the viewport centre.
  • Give sizes at paper size, not model size.
  • Lock the viewport first, or a later zoom moves the area the grid was drawn for.

Download and details

NameGridRef — a labelled coordinate grid over a layout viewport
DownloadGridRef.lsp — 21.3 KB, plain AutoLISP source. Downloads directly; no zip to unpack.
TypeAutoCAD AutoLISP routine
CommandGRIDREF
Requiresnothing beyond a CAD platform with AutoLISP.
Source size21.3 KB, 451 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

  • VIEWFRAME LISP — draw what each viewport covers, in model space
  • PORTLOCK LISP — lock every viewport before gridding
  • Grid systems on drawings — setout, naming and direction conventions
  • 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