• 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

MOONPHASE LISP: Calculate and Draw the Phase of the Moon

August 6, 2026

MOONPHASE works out the phase of the moon for today or any date you give, reports it, and draws the moon at that phase.

What MoonPhase does

The drawing is the novelty. The calculation is the substance: it finds the times of the new moons either side of the date by summing periodic terms in the moon’s and sun’s mean anomalies, and interpolates between them. It is good to about two minutes.

How to use it

  1. Load the routine with APPLOAD, or put it on your support file search path.
  2. Type MOONPHASE.
  3. Accept today’s date or give another.
  4. Pick a point to draw the disc.

How it works

The lunar month is not constant, and that is the whole difficulty. It averages 29.53 days but varies by several hours either side, because the moon’s orbit is elliptical and the sun perturbs it.

Dividing the days since a known new moon by 29.53 is wrong by up to most of a day — which is the difference between a crescent and a quarter, and perfectly visible in the drawing.

So the series carries terms in the sun’s mean anomaly, the moon’s mean anomaly and the moon’s argument of latitude, with secular corrections in the centuries since 1899.5. The largest correction, the −0.4068 sin term in the moon’s anomaly, is worth nearly ten hours on its own.

What gets drawn is the disc as a circle and the terminator — the line between light and dark — as an ellipse across it. The terminator’s width is the cosine of the phase angle, which is what makes it a straight line at the quarters, a narrow ellipse near new and full, and correctly bowed either way between.

Notes and limits

  • Accurate to about two minutes on the new moon times it interpolates between.
  • Nothing is left in the drawing but the geometry. Drawing the shape by making a block of a semicircular arc and re-inserting it with an X scale leaves a block definition named after the time of day in every drawing it touches.
  • The terminator is an ellipse, not an arc — which is what makes the phase read correctly.
  • One undo group covers the drawing.

Download and details

NameMoonPhase — calculate and draw the phase of the moon
DownloadMoonPhase.lsp — 12.5 KB, plain AutoLISP source. Downloads directly; no zip to unpack.
TypeAutoCAD AutoLISP routine
CommandMOONPHASE
Requiresnothing beyond a CAD platform with AutoLISP.
Source size12.5 KB, 315 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

  • CLOCKFACE LISP — the other one that reads the clock and draws it
  • CANNON LISP — honest physics, drawn as temporary vectors
  • 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