When you ask an AI for "SpongeBob's house in LEGO", the hard part isn't the shape. The hard part is that a shape made of cubes isn't a LEGO model. Real builders don't stack 1×1 bricks into a block. They cross the layers so they lock, use one big plate for a base, leave the inside hollow, and use as few kinds of parts as possible, so you can actually collect them.
This post covers the packer I wrote for Mister Blocks, and the rules it learned, mostly from me looking at a build and saying "nobody would build it like that".

Bluey's Queenslander house: 128 pieces, 15 steps. One of the LEGO buildings the packer made.
Step 1: draw it like a top view, layer by layer
A build is described as a stack of layers. Each one is a top-down drawing where every character is one stud of a colour:
const g = brickGrid({ W: 16, D: 12, colors: { Y: ['#f2cd37', 'Yellow'], W: ['#ffffff', 'White'], G: ['#4b9f4a', 'Green'], R: ['#c91a09', 'Red'] } }); g.base(0, 'G'); // one base, from the biggest real plates g.layer(1, 'brick', ['..YYYY..', '..YWWY..']); // rows of studs, '.' = empty g.slope(4, 2, 0, 2, 4, '+z', 'R'); // hand-placed parts take their cells first g.tall(2, 0, 0, 1, 2, 'W', 3); // one tall brick instead of three layers Then pack() turns each layer into real bricks. That's where all the rules live.
Rule 1: cross the layers, stagger the seams
The first version filled each layer greedily with the biggest brick that fit. It looked right in 3D and would have fallen apart in your hands: every layer had its seams in the same place, so the model was really a set of loose columns.
So odd layers prefer pieces along one axis and even layers along the other. And when several pieces fit, the packer scores them by area plus half again if the piece bridges two or more pieces of the layer below. That's what builders do without thinking: put the 2×4 across the join.
Rule 2: one base, from real plates
A base is one layer of the biggest plates LEGO actually makes (16×16, 8×16, 6×16…), never two thin layers glued together. And a plate never sits exactly on an identical plate, because that pair only holds itself.

Gundam RX-78-2: 91 pieces. More in LEGO mechs and anime builds.
Rule 3: nothing rests on air
This one took the longest. A drawing happily puts a brick where there is nothing underneath it: an arm sticking out, the brim of a roof. In 3D it looks fine. In plastic it falls off.
The fix has two parts:
- Overhangs are packed first, in a piece that also covers a cell that does sit on a stud. The overhanging piece is held from below, the way you'd build it.
- If a lone overhang still can't be bridged, its colour is carried inward along the shortest path of drawn cells to the nearest supported cell, and the layer is packed again. Those inside cells are almost always hidden, so the look doesn't change, but now one piece spans from the support to the overhang.
A cell that one overhang has already claimed for its colour is never taken back. Without that rule, two overhangs side by side kept trading colours forever.
The report at the end fails the build if any piece has nothing under it.
Rule 4: hollow inside
A solid 2,000-piece sculpture is a 2,000-piece sculpture nobody will build. Real display models are hollow.
After packing, the packer flood-fills "outside air" from beyond the grid and above the top layer. Every drawn piece that touches no outside air (from the sides, above or below) can't be seen, so it's removed, one at a time, as long as the model still holds together. It only ever removes pieces, so a build never gets bigger.

Mega Greninja as a 1,183-piece sculpture, with clear supports added until the whole model is one connected piece. See all LEGO sculptures and Pokémon builds.
Rule 5: a short parts list
My first review of a small build was blunt: it was hard to collect and hard to build when such a simple model needed 25 different kinds of parts.
So after packing, the packer keeps trying to drop the rarest part type (one shape in one colour) and repack, as long as the list gets shorter and the model still holds together. One fewer kind of part is worth up to 4 extra pieces. 1×1s always stay as the fallback.
There's one guard: if a ban only works because the repair recoloured cells (an eye turned into face colour), it's rejected. A shorter list isn't worth erasing the design.
Rule 6: tall bricks, like a person would use
Then came the second round of review: why three stacked 1×2 bricks when there's a 3-high block? Why three plates when a brick is the same height?
restack walks every straight vertical run of pieces with the same footprint and colour, and re-cuts it into the fewest real pieces: tall bricks first (1×2×5, 1×2×3, 2×2×3…), then bricks, then plates. Only parts that really exist are allowed; asking for a tall brick LEGO doesn't make throws an error that lists the ones it does.
It's always safe, which is why it runs on every build: inside a run, every face is covered by the run itself, so nothing else was touching those faces. The top and bottom of the run (what it clips onto, and what clips onto it) stay exactly the same. A chimney becomes a 2×2×3; a wall becomes one 1×6×5.

Totoro: 156 pieces, 13 steps. Also in movie builds.
Rule 7: every step must be buildable
Finally the steps. Layers are grouped into instruction steps of at most 18 pieces, and arms or tails can be named sub-assemblies with their own step. Then a build-order pass checks each step: if new pieces would only be held by a piece that arrives later, that piece is brought forward. Moving a piece earlier can't break an earlier step, and a later step only gains support, so it repeats until nothing changes.
What it adds up to
Each rule came from looking at a finished build and asking whether a person would really build it that way. None of them are clever on their own. Together they're the difference between "a 3D shape in LEGO colours" and something my son can actually put together on the table.
If you want to see the results, every build has free step-by-step instructions you can turn in 3D and print. Browse by category: buildings, anime, mechs, sculptures, TV shows or easy builds. Or snap your own pile of bricks at misterblocks.com and get build ideas from exactly what you have.
Unofficial fan builds. LEGO® is a trademark of the LEGO Group, which does not sponsor or endorse this site. Characters and brands belong to their owners.
