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
- Load the routine with
APPLOAD, or put it on your support file search path. - Type
SURFPLOT. - Type the equation in LISP form, using
xandy. - Give the range in each direction and the number of steps.
- 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 + yis(+ 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
| Name | SurfacePlot — plot z = f(x,y) as a 3D mesh |
| Download | SurfacePlot.lsp — 9.3 KB, plain AutoLISP source. Downloads directly; no zip to unpack. |
| Type | AutoCAD AutoLISP routine |
| Command | SURFPLOT |
| Requires | nothing beyond a CAD platform with AutoLISP. |
| Source size | 9.3 KB, 192 lines |
| Error handling | Yes — a *error* handler restores every system variable it changed, on cancel as well as on error. |
| Undo | The whole operation is wrapped in a single undo group, so one U reverses all of it. |
| Compatibility | AutoCAD (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. |
| Author | YZ, August 2026 |
| Licence | Free 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