• 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

SURFPLOT LISP: Plot z = f(x,y) as a 3D Mesh in AutoCAD

August 6, 2026

SURFPLOT draws z = f(x,y) as a 3D mesh over a range you give. Saddles, domes, ripples, decay curves, anything that can be written as an expression.

What SurfacePlot does

The equation is typed in LISP form, which is prefix notation — the operator first:

(* 0.2 (+ (* x x) (* y y)))              a paraboloid
(* 5 (sin (/ (sqrt (+ (* x x) (* y y))) 3)))   ripples
(/ (* x y) 10)                           a saddle
(* 10 (exp (- (* 0.05 (+ (* x x) (* y y))))))  a bell

Anything AutoLISP can evaluate will do: sin cos atan sqrt expt exp log abs.

How to use it

  1. Load the routine with APPLOAD, or put it on your support file search path.
  2. Type SURFPLOT.
  3. Type the equation in LISP form, using x and y.
  4. Give the range in each direction and the number of steps.
  5. Pick where it goes.

How it works

The expression is evaluated directly with (eval (read string)). It is checked once before the mesh is built, so a mistake in the equation is reported plainly rather than surfacing as something stranger later on.

The mesh is then generated point by point across the range and handed to 3DMESH.

It is worth knowing what this replaces. The original did not plot anything. It wrote a LISP file to disk, line by line, containing a program that would do the plotting — then wrote a second file, a script, whose job was to load the first one and run it. Then it ran the script.

Sixty lines of the source were string concatenation assembling that program, with (chr 34) standing in for every quotation mark. Any mistake in the equation surfaced as a syntax error in a generated file the user never saw. It also left both files behind, and the generated one took the name the user gave with no check that it was not something already on disk.

None of that machinery is needed, because AutoLISP can evaluate an expression on the spot. Nothing is written to disk and nothing is left behind.

Notes and limits

  • Prefix notation. x + y is (+ x y).
  • More steps means a smoother surface and a heavier mesh; start coarse and refine.
  • Nothing is written to disk.
  • One undo group covers the mesh.

Download and details

NameSurfacePlot — plot z = f(x,y) as a 3D mesh
DownloadSurfacePlot.lsp — 9.3 KB, plain AutoLISP source. Downloads directly; no zip to unpack.
TypeAutoCAD AutoLISP routine
CommandSURFPLOT
Requiresnothing beyond a CAD platform with AutoLISP.
Source size9.3 KB, 192 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

  • GRIDSURFACE LISP — a mesh from surveyed levels rather than an equation
  • GRAPHGRID LISP — the grid to plot it on in 2D
  • POLY3D LISP — lifting flat geometry into 3D
  • 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