The case of the loose double cheese

Posted by ,

Ronny Nussbaum has written this article about solving a tricky problem -- one we've probably all experienced at one time or another -- with technology:

I just finished building the largest LEGO set in the world: 75192 Millennium Falcon. A month earlier, I built the amazing vertical stand MOC by Efferman and I was getting ready to mount my Millennium Falcon on it. Upon trying to move it, I realized that a piece fell off. The piece’s official name is Roof Tile 1 X 2 X 2/3, Abs, which looks like a couple of 1x1 “cheese” pieces that are attached together, and so I named it the “Double Cheese” piece.

I am a perfectionist, and had to put the piece back, but how could I find where it fell off from?

I could have gone over the entire instructions and looked for all the steps that include the double cheese. The instruction manual has close to 1,400 steps, and so I decided to take a different approach.

In short, I was able to find a PDF analysis tool that helped me find the piece’s location in every step of the instructions. That was my use case, but you may find another reason to find every place that a certain piece appears.

This article describes the steps I took. The instructions and commands you’ll see below were tested on a Mac. They should work for other *nix systems. If this is of interest to people, I may write a version that works on the PC.

A little about what we’re about to do

We will be looking for the double cheese piece in the Millennium Falcon PDF and will find all the steps in which it appears. If you want to follow along, you’ll have to download the instructions from LEGO’s site here: https://www.lego.com/biassets/bi/6218872.pdf.

The instructions below will reference the file name you see in the URL above (6218872.pdf).

A typical building instructions PDF page contains a picture showing the pieces you’ll need in the upcoming building step. Here’s an example of step 188 from page 95 of the Millennium Falcon PDF:

View image at flickr

The picture consists of 8 pictures of parts, a text element containing the number “188”, and a bunch of “1x” and “2x” text elements that indicate the piece counts for this step.

Each of the 8 pieces you see in the picture has its own unique ID within the PDF, and when a certain piece appears in another step, its ID is referenced there (hidden to you, but it’s in the PDF file structure). What this means is that if the double cheese piece appears in page 95 and page 112 (which you’ll shortly see - it really does), then its ID in each of those pages is the same In this case, its unique ID is 11204.

If we find a piece’s unique ID number, we can run a tool, and ask “show me all the pages in which ID 11204 appears.” This is what we’ll do.

When I started this process I thought that finding each piece’s unique ID will be easy. After all, the entire list of pieces used in a model is published in the last few pages of the PDF.

Unfortunately, I learned that the pictures of the pieces that appear in the instructions’ final pages are not the same as the pictures that appear in the actual building steps.

View image at flickr

The double cheese graphic above was taken from page 465 of the instructions.

The highlighted piece picture is not the same as the double cheese slope that is shown on the top of this page.

This is unfortunate, and complicates things a little. It means that if you’re looking for all iterations of a certain piece, you’ll have to manually find one page in which it appears. In the case double cheese piece, the first appearance is on page 95, step 188. Now that we found one appearance of our piece, we can proceed to find all the rest in a much faster way.


Step 1

Get the PDF you want to analyze and place it in a directory of its own. We’ll be extracting some files from it, and I find this approach eliminates cluttering my machine.


Step 2

Install the MUPDF package using Brew.

  1. Launch Terminal by pressing command+space, type terminal and hit the Enter key.
  2. Run ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null
  3. Type brew install mupdf and hit the Enter key.

During the installation you may be notified that there are other packages that need to be installed. Read the output on the screen, and it’ll let you know how to install anything that may be missing.


Step 3

Switch to the directory where you placed the PDF in.


Step 4

We know that the double cheese piece appears for the first time in page 95, so we’ll type the following:

mutool show 6218872.pdf p|grep 'page 95 '

This outputs the following to the screen:

page 95 = 1582 0 R

The important thing to note here is the 1582. We’ll be using it shortly, but first, some notes:

  • If you’re using a different PDF name, you’ll need to replace the 6218872.pdf with that PDF’s name.
  • The “95 “ at the end of the command references the page we had to manually find, where our double cheese piece first appears.
  • Note the space after the “95”.


Step 5

Run the following command:

array=($(mutool show 6218872.pdf p 1582|grep Im[0-9]|cut -d\/ -f2|cut -d" " -f2));for i in "${array[@]}"; do mutool extract 6218872.pdf $i; done

This will extract all the pictures from page 95 into the current directory.

Note that as before, the PDF name will have to change if you’re extracting from another PDF.

Also note the “1582” from the previous step. You will likely have a different number if you’re looking for another piece or looking in another PDF altogether.


Step 6

Browse through the current directory and find the image file containing the double cheese picture. You’ll soon find that the file’s name is img-11204.png.


Step 7

To find all the locations that this image appears in the PDF, run the following command:

mutool info -I 6218872.pdf 1-468|grep '(11204 0'|cut -f2

This outputs the following to the screen, which are the page numbers.

95

112

122

129

130

131

132

146

372

376

381

384

The important thing to note here is the PDF page range (1-468) and the part number we’re looking for, which is 11204.


Something to pay attention to

When I was developing this manual, I came across an interesting situation.

I was on page 52, and wanted to see places in which this piece appears:

Unfortunately, on the same page, the instructions also show the same piece but in a different angle:

View image at flickr

Make sure that the piece you’re looking for is the same as the one appearing by the step number:

View image at flickr


If you try this and receive any errors, please e-mail me at RonnyNussbaum at gmail.com. I have done some testing on a couple of PDFs, and solved most of the issues, but some may remain. I hope this helps you in some way.

 

Sponsored content

34 comments on this article

Gravatar
By in Netherlands,

I scroll a lot through building instruction PDFs to find how certain pieces are used. I don't know if it would be any faster if I used your method since you have to find the first piece manually.

Besides, you mentioned that this guide may not work on PC, but I would love to see a guide for PC so I can try it out myself.

Gravatar
By in United Kingdom,

Just wondering, but it seems that the most time-consuming part of this is finding the ID in the first place - you have to manually look through until you find it.

Could you therefore not write another program, which extracts ALL images of all parts used on every page? It could perhaps check before saving them whether they've been saved already - or it may just overwrite the existing image if it has been.

By doing this, you could then simply look through the long list of images it has saved, and find the number that way.

Gravatar
By in Netherlands,

Nice article!

So, the important question, did you find where your double cheese fell off? Was it worth it? ;)

Gravatar
By in Norway,

Fun read, great case for simple code for repetitive task.

Did you consider scanning / parsing the LDD/LXF file?
Might be more suitable for generic “when are parts X used” type of queries.

Gravatar
By in Australia,

I can't wait for Part 2: which part the piece fell from! Interesting usage and application of the pdf, but you left us all hanging by not telling us if you solved the case or not! Thats clickbait! >:( Perhaps reword the topic? :)

Gravatar
By in United Kingdom,

That's awesome! I've spent a lot of time searching through instcuctions when I've ended up with a 'spare' that I know shouldn't be spare. It must have been very satisfying working out how to solve this puzzle.

Gravatar
By in United States,

Thanks for all the great feedback. I will address each of the comments above individually:
@CreativeTim: Thank you. You're right about the slowness of the method. I've been tossing and turning about it for a few days. There may be a faster way. See my reply to @Paperballpark below. I'm more of a PC person myself. I switched to a Mac about a year ago. Interestingly, your question may end up simplifying the solution. See if the method mention to @Paperballpark helps you as well. If you're well-versed in using the Windows command prompt, you could easily review the instructions and do a 1-to-1 conversion to Windows. The main problem is with using commands like "grep". I'll find some time and do this. Keep checking the comments here.
I may ask Huw to change the article when the instructions are available :)

@Paperballpark: Thank you. That was an idea I played with, and based on your feedback I think it's worth mentioning, and will probably make it easier for many people.
To implement your idea, people should do the following:

1) Ignore step 4
2) Replace step 5 with running this command: mutool extract 6218872.pdf
3) Find an image viewer of choice, and sort the images by file size. The smaller images contain the pieces usually.
4) Continue with steps 6 and 7.

It's worth mentioning that this method extracts everything!
This will give you some cool pictures from the PDF and is worth running at least once. There's some cool stuff there!
Also worth mentioning: the comments in "Something to pay attention to" are still relevant, so make sure you read it.

@sparrownest: Thank you. I did not consider that. Where would I find an LDD/LXF file for the Millennium Falcon? My approach was to scan the PDF from the beginning, and I didn't consider other approaches but would love to hear more.

@TWP, @thehornedrat: Thank you both. No... I haven't found where it fell from yet! One of my (many, according to the wife) personality "issues" is that once I get a problem, I have to solve it. I was so concentrated on this problem, that I forgot completely about what had initiated it in the first place. Perhaps today I'll look for it and put it in its rightful place! Part 2: "revenge of the cheese" is right around the corner :)

@Brainslugged: Thank you. I'm glad it can help you and others in some way.

Gravatar
By in United States,

This is awesome. I've found myself in similar positions a lot lately, as my wife and I enjoy building sets of all sizes "with" our three-year-old. He's more helpful than you'd think, but the distraction of a toddler while building an Architecture or Creator set means that we frequently end up with unused pieces which cannot possibly have been included as "extras."

Gravatar
By in United States,

Interesting project! It's fun to see the inner workings of something that you wouldn't think would be exposed to the end user.

If I understand correctly, the method relies on the idea that the same bit-for-bit picture of a part is used in every step inventory box. Since this picture differs from the one used in the overall inventory pages, I presume that the PDF authors have no qualms about using different size pictures in different circumstances. Do we know with certainty that every step inventory box uses the same picture? I can imagine a step with many parts using smaller pictures to fit them all in the inventory box.

Gravatar
By in United States,

Windows users rejoice: install Git Bash, and it comes with a Bash environment plus a whole slew of command-line tools including grep. I taught a class on command line and this worked really well for my students.

Gravatar
By in United States,

@OpenBagTwo: Thank you. I hope this helps you with the tornado forces of a 3-year-old. My wife and I are way past that phase :)

@Markwell: Thank you. Great comment. You understand correctly. Your presumption is also correct. In every test that I have done, and with multiple PDFs, I always saw two version of a part's picture: the one used throughout the instructions, and the one showing in the inventory at the end of the PDF. Nevertheless, a situation like the one you describe could potentially happen. See my comment above about extracting all pictures from the PDF. This should help you if you ever need to follow the steps in this manual.

@buildalot: Thank you. This saves me a lot of time too - now that I don't need to convert the instructions to the PC version!

Gravatar
By in United States,

That was a really cool article! Thanks for the instructions!

@Huw... In the end, where had it fallen off from?

Gravatar
By in United Kingdom,

@RonnyN I hope it helps someone. Not me though, as I'm a PC user! I've never liked Macs, for a few reasons. :)

Gravatar
By in Belgium,

Great article, thanks for sharing!

Gravatar
By in United States,

@bbeck018: Thank you. I haven't yet looked at where the piece fell from :)

@Paperballpark: read the response from @buildalot. You could then use the instructions on a PC.

@sparrownest: Thanks for the info.

@Snowhitie: Thank you!

Gravatar
By in United States,

I'm more interestef in where it was on the Falcon before it came off than how I can locate it, lol.

Gravatar
By in Australia,

I believe windows 10 has the ability to install a version of Ubuntu as a command prompt. Better than installing cygwin as it is more fiddly to get working. Cygwin gives a Linux command line for windows users. Microsoft should just implement a version of Linux command line as the default to help windows users get used to a decent command line tool. Bash is sooo much easier to use.

Gravatar
By in United States,

Very cool article. I’ve found the parts list at the end of sets invaluable because knowing how many should be there is a good starting point in counting pieces on a set. However this only helps with small / medium sets. Your program seems like a great tool for any sized set.

Gravatar
By in Germany,

Never had this use-case yet, but fascinating nonetheless. Might find a reason to try this out one day, as soon as it becomes available on a PC.

Gravatar
By in United States,

@BSpaceMan: Thank you.

@AustinPowers: Thank you. Read some of the comments here. There's a way to run this on a PC with an emulator you can get for free.

Gravatar
By in Spain,

Great! It is very useful for people who partially disassemble big sets for temporary use of some parts (my UNiMOG is a big parts provider), and later have to put those parts back

Gravatar
By in Indonesia,

Very interesting :) You should make a way to do this on the PC.

Gravatar
By in Italy,

@RonnyN
@sparrownest

Even better method:
- get the lxf file from the web
- open the LXF file with LDD (it will be not 100% accurate, but the double cheese slope is a common part and it should be placed correctly)
- add a double cheese slope with the proper colour in the scene
- select it with the "shape and colour" selection tool: all the same parts of the same colour will be selectet
- change the colour of the selection with a noticeable colour.
- (optional) change the colour of the rest of the model with a pale colour (temporarily hiding the previous selection to avoid it will be selected with the rest of the model)

Now it is easy to detect and move all the selected bricks.

Gravatar
By in United States,

@Calabar. Thank you. However, the "it will be not 100% accurate" won't work for me.

Is the LXF file for the 75192 MF available now?

Gravatar
By in United States,

There is an easier way to do this for Windows (and maybe Mac) users searching PDFs. Purchase/download Bluebeam Revu and use it's "visual search" feature. See https://support.bluebeam.com/training-videos/#visual-search . Very easy. Found all instances of the tan and grey double cheese slope pieces in one search. Found all instances of that technic axle piece(?) as well.

Gravatar
By in United States,

@NuttaMastaBuilda: Thank you, but "easy"? It's $350 for a single license...

Gravatar
By in United States,

@RonnyN: Try Bluebeam Vu for Windows or iPad. Vu is their free PDF viewer. I haven't tried either version of Vu, but the Vu product page says you can search text and graphics. I imagine it would be close to or identical to the way Revu does it. And yes, on Revu, it is "easy." :)

Gravatar
By in Canada,

@Huw: I thought I was the only one to call this piece "double cheese". I wonder how many other AFOL's, TFOL's, KFOL's also call this piece "double cheese"?

Gravatar
By in United States,

This is a great tool. I however see trying to look at the build for every single step that used a particular piece to see if the piece is there or not will take forever. I too found a piece on the floor after building my Falcon and am worried I wont be able to see all of the places it may have come from.

Gravatar
By in United States,

@Tddunbar: Thank you. See my first response above. You can extract all the images, sort by image (not file) size, and relatively quickly find the picture of the piece. Then, follow the steps I outlined in my first reply above, and you'll be golden. You DO NOT have to find the first step in the instructions in which the piece appears in.

Gravatar
By in Germany,

@RonnyN:
"No... I haven't found where it fell from yet! One of my (many, according to the wife) personality "issues" is that once I get a problem, I have to solve it. I was so concentrated on this problem, that I forgot completely about what had initiated it in the first place."

http://www.dailymotion.com/video/x4ireco
30:51 - 31:18 :-)

Gravatar
By in United States,

@The Hacker: Thank you!

Return to home page »