As I’ve mentioned before, I’m off the deep end. I’ve purchased a couple of Akro-Mils drawer cabinets to sort my Lego bricks in. Already, I think I need more. Every drawer in the 64 drawer unit has at least one type of element in it, and most of the 24 does as well. I’ve completed the free-range red, yellow, green, blue, and brown/tan families as well as nearly a drawer-full of greebling I had. I have plenty of bricks that are packaged with their set. I have sets that are currently built. And I have sets that have never been built. That’s all going to have to be dealt with at some point as well. Of the free-range bricks, I have black, white, light grey, and dark grey families to sort through.

But wait, there’s more

I’m looking at at least 6 cabinets, maybe more. Probably more. I’m not done with free-range and I definitely need another cabinet. I’m wondering if I should get some 44 drawer units. It’s basically a half-and-half version. 32 on top and 12 on bottom. I’m thinking I could arrange them like so:

Artist's rendering. Ok, I just pasted three images together

And imagine that running along the wall. Or I could do two 64 units on top of one or two 24 units. Each cabinet is 16 inches tall. So three high would be 4 feet, while four high would be 5’4″. It all depends on if I want them to the floor or not, I guess. I’ll probably go three high. Which means I should buy them in groups of three. So I should get two 44 units and another each of the 64 and 24 to even things out.

Of course, I have to overcomplicate it

Once things are in other things, I would need things to tell me which things are in which things. There are plenty of labels you can get online. Brick Architect has a pretty comprehensive set here. But I’m pretty sure I can make things harder on myself. I’ve been looking for a project to use NFC tags. I’ve even purchased some quarter sized sticker tags.

My vague idea is to put a tag on each drawer. And then encode the tag with the contents of the drawer. Then I can hold my phone up to the drawer and it would show me the contents. Or I could have an entire inventory I want to pull and scan the drawer to tell me if it contains something in the list. Also, be able to look up a piece on an app and have it tell me what drawer to look in.

Now, I know this could partly be solved by simple organization. Having bricks and plates sorted by size goes a long way to knowing where stuff is. But, you know, it’s an excuse to do stuff.

So many images

To do what I’m thinking, I would like to use Lego’s official part numbers. Now, each piece has at least two numbers. There’s what I call the shape number and the part number. The shape number is pretty much what it sounds like, a number assigned to the shape of the brick itself. For instance, the iconic 2×4 brick is 3001. Regardless of what it’s made out of or what color it is. A red 2×4 brick is 3001, a translucent purple with glitter 2×4 brick is also 3001. But if you are pulling bricks, color matters. So each brick also has a unique number for that particular color/material of the brick.

Now, there seems to have been some attempt to normalize these numbers. The white 2×4 brick is numbered 300101 and the red 2×4 brick is numbered 300121. It follows a pattern of {SHAPE NUMBER}{COLOR CODE}, where 01 is the code for white and 21 is the code for red. But something broke down somewhere, because the part number for the lime green 1×4 brick is 4112838 while the part number is 3010. Maybe they ran into a collision somewhere and just went sequential? Maybe they came up with over 100 colors? Or maybe they weren’t managing the numbering by hand anymore, so it didn’t matter that they followed a pattern.

But to use these numbers in an inventory system, you need to get them. There are over 13,000 bricks currently in Lego’s Pick a Brick shop. Thirty-four pages if you get them 400 to a page. So, we scrape. Luckily, Lego makes use of datasets, so everything is neatly tagged for us. Generating a list of part numbers and descriptions is relatively painless. But I had to go one step further. Because while PLATE 1X5 is relatively easy to visualize, PLATE 1X2 W. VERTICAL GRIP is less easy. So I decided I wanted all of the images as well.

Once again, easy enough to pull the URL of the image from the HTML element, but it’s still a matter of making all 13,000+ requests and storing the images. Now, the images themselves are 192×192 JPEGs, roughly a few KB each. My back of napkin math says that it’ll take about 100MB to store them all. Not too bad. As of right now, I’m about 3100 images deep. Just 26 more pages to collect.

And I’ll still be missing some

I do know that there are elements that have been retired for a while that I have. These are not on Lego’s site even if you show the out of stock items. I should be able to get the numbers and images from Bricklink. I might just handle those on a case by case basis.

Next Steps

As that’s happening, I can start work on the app/tag part of things. I looked up the tags I got and they can store 504 bytes of information. Not a lot, but we can work with it. If we can create our own custom data format, we can get clever. With 4 bytes, we can store numbers from 1 to 2^32-1. Which is currently large enough to hold any part or shape number. If we use it as a bitflag, 1 byte is enough to indicate all the colors contained within. We can even get a little clever with this as translucent versions of a color can be indicated by a modifier flag. So, with 5 bytes, we can hold the part number, or the shape number and all the colors of that shape contained within. With 504 bytes, we can hold up to 100 of these. Or we can put in other information.

Which is the entire point of downloading this information. I want to be able to look up the info, check it, and write it to a tag.

So that’s what I’ll have to do next, lock down the tag format. Then be able to read and write tag information.

By toast