Checking Revit's sun against the almanac
How a one-click planning shadow study came out of distrusting Revit's sun, compositing frames outside Revit, and learning the difference between pyRevit's two Pythons.
Toronto asks for a shadow study with most planning applications. The format is precise: four dates, the equinoxes and solstices; ten hourly instants a day, from 9:18 in the morning to 6:18 in the evening; the shadows of what exists and the shadows of what is proposed, in the City’s colours, on twenty 11×17 sheets. Most firms that submit in the city have made one, usually by hand: set the sun, render, export, repeat forty times, then spend an afternoon in a page-layout tool.
I run the digital practice group at an architecture firm, and this was the task people asked about most. So we built it into our Revit toolbar as a single button. What follows is less about the button than about what we had to find out to make the button honest.
Why 9:18
The odd minute is the first clue that this is not a casual spec. 9:18 is Toronto’s solar noon minus four hours: the City anchors the day to the sun’s highest point, not to the clock. That means the study is really specified in solar terms, and anything that gets the sun wrong by a few minutes gets every shadow wrong by a few degrees.
The second clue is December. At 6:18 in the evening on the 21st of December, the sun in Toronto is below the horizon. The City’s terms handle this by reusing the 5:18 frame under a full wash. Our tool has to know that too, which means it has to know where the sun is, independently of whatever Revit thinks.
The almanac
So the first thing we wrote was not Revit code. It was a solar position module in plain Python, no dependencies, implementing NOAA’s calculator algorithm after Meeus, good to about a hundredth of a degree. Its docstring says why it exists:
"""Sun position, independent of Revit -- no imports beyond the stdlib.
NOAA's solar calculator algorithm (after Meeus, Astronomical Algorithms),
good to about 0.01 deg. It exists so the shadow tools can check the sun
Revit actually renders for a frame against an instant we chose, before
exporting it.
"""
Here it is for the June solstice, the four corners of the day, and the two December instants that matter. Times are labelled the way the study labels them, as UTC-4 throughout:
date local UTC azimuth altitude
2026-06-21 09:18 13:18Z 91.8° 37.1°
2026-06-21 12:18 16:18Z 143.1° 66.2°
2026-06-21 13:18 17:18Z 179.1° 69.8°
2026-06-21 18:18 22:18Z 277.7° 26.8°
2026-12-21 17:18 21:18Z 233.1° 3.0°
2026-12-21 18:18 22:18Z 243.4° -6.3° below the horizon
Solar noon sits between 12:18 and 13:18, which is where 9:18 came from. December’s last frame is well past sunset, with the sun more than six degrees below the horizon, and even 5:18 is only three degrees above it. The table took a few seconds to produce and it is the ground truth for everything else.
What Revit does with a time
Revit’s sun settings take a wall-clock time and a place. What they do with it is not documented to the precision a planning submission needs, so we ran a throwaway spike against a real model and wrote down what we found. Three things, cheapest first:
Revit reads the StartDateAndTime you give it with a particular assumption about what kind of time it is, local or universal, and that assumption is not the obvious one. Setting 9:18 and rendering produced a frame whose sun matched a different instant than the one we meant. The rule that reproduces the City’s instants, found by comparing rendered frames to the almanac, is: hand Revit the target UTC time plus the site’s time zone, plus one hour if the site says it uses daylight saving. Written down it looks like a workaround. In practice it is the only formula that makes every frame match.
The odd :18 minute does survive a still-image render. We checked, because a rounding to the hour would have been invisible on screen and wrong on paper.
And true north has a sign, and the sign is the opposite of what the first pass assumed. Every azimuth was mirrored until that was fixed.

Compositing outside Revit
Revit can render a shadow. It cannot render “the shadow that is new because of this building” while keeping “the shadow that was already there” in a different colour, with the overlap handled sensibly. That is what the City wants to see: existing shadow in one tone, net new shadow in another, both on the same sheet.
So the tool renders existing and proposed as separate frames and composites them afterwards, in Python with numpy and Pillow. The first version kept each layer’s colour and, where both cast shadow, reverted only the intersection, using the lower of the two alphas. It looked right on simple sites. On a dense block, where most of the proposed shadow falls on ground that was already shaded by the neighbours, it under-stated the overlap and the net-new area read as larger than it was.
The current version multiplies the layers where they overlap. Existing-only stays existing. New-only stays new. Both-at-once is visibly both, darker, and the reader can tell at a glance how much of the new building’s shadow lands on ground that was already in shade. There is a guard in the spec test so nobody quietly changes the blend mode again.
Two Pythons
pyRevit, which our toolbar runs on, offers two engines: IronPython 2.7, which has been there for a decade, and a bundled CPython 3 through pythonnet. The shadow tool needed numpy and Pillow, so it lives in CPython. Other parts of the toolbar are older and live in IronPython. The two do not behave the same, and the differences cost real time.
Under CPython, pythonnet cannot OR two values of a .NET flags enumeration together. TaskDialogCommonButtons.Yes | TaskDialogCommonButtons.No raises. The fix is to construct the enum from the integer: Yes | No is 24. It is in a comment now so nobody tries to tidy it.
pyRevit’s Reload button does not clear sys.modules under CPython, so editing a library module during development did nothing until Revit was restarted. The toolbar now reloads its own packages explicitly, leaves first, on reload.
Under IronPython, os.fsync on a file opened with io.open raises “Bad file descriptor”. Every save from one of our older tools was failing with that error, and for a week it was blamed on the file share, because that is what an I/O error on a network path looks like. It was the engine.
And the one that cost the most: Revit’s SetFilterOverrides takes the ElementId of a filter, not the filter object. Passing the object threw on every call, the call was inside a broad try/except that logged nothing, and a feature that faded non-selected elements in a view simply never did anything. Nobody noticed for a month, because the view looked the same as before. A code review found it, not a user.
Where it landed
The button produces the twenty sheets in a few minutes. Every frame has been checked against the almanac before export. The December wash is applied automatically. The same almanac module now underpins a second tool that reads a model’s actual solar settings back and flags anything that does not match the project’s location.
The lesson I keep coming back to is the first one. Revit’s sun is probably right. For a document a city will accept or reject, probably is not a number, and the cost of knowing was one small Python file with no dependencies.