TransClear

TransClear

A Windows thumbnail handler for LEGO Digital Designer (LXF) files.

As previously written, I would like to write about all my Github projects on this blog, so with this, here is my second post in this series. Let me present TransClear, a thumbnail handler for LXF-files. A small extension for Windows Explorer that will replace the normal LDD-icon for a LXF -file with an image of its contents. The image below illustrates the change.

Demo

The extension does not generate the image itself, it simply uses an already generated image found inside the LXF-file. An image that is generated by LDD when you save the LXF-file.

The code is open source and can be viewed/downloaded from Github.

How to install and use it

Requirements:

  • Windows Vista or better
  • .NET Framework 4.5 installed. Should be installed by default if you have a newer Windows version.

Unpack the zip-file, run Installer.exe and click the big button marked “Install”. TransClear should now be loaded into the memory and be used every time Windows asks for a thumbnail for a LXF-file.

If you get an error during install and are running Windows 10, you might need to “unblock” the files. On both “Installer.exe” and “LxfHandler.dll”, do the following: right-click on the file, select properties and under the General tab, look for a checkbox or button that says “Unblock” and click it. That should fix the issue.

Please note that the handler will stop working if you change the location of the TransClear files. If you want to move them, uninstall TransClear first and then install TransClear again after the move.

If you are not seeing any thumbnails in Windows

At first you’ll need to check that you are using the correct view while browsing files. Right click on the Explorer window, select “View” and then “Large Icons”. (A few other views works as well, but “Large Icons” is my preferred view when looking at LXF-files.)

Secondly, Windows might already have generated thumbnails for the files. Windows will do this for files even when a thumbnail handler is missing. This means that the LXF-files might not get a new thumbnail until they have been modified or after the thumbnail cache has been cleared. Try modifying a LXF-file to see if a new thumbnail appears. (If you want to try clearing the cache, you can find guides on how to by searching on Google)

If you don’t see any thumbnails for any files (including non LXF-file), your Windows might be configured to not generate them at all (This you can also google how to fix).

Known issue

For some reason I can’t get thumbnails to show consistently in the “Open File”-dialog window for LDD. Very annoying.

Origin and Development

When I returned to LEGO as an adult, I quickly started to use LEGO Digital Designer to plan almost all my builds. And as my library of digital builds grew, it became harder and harder to get an overview and find the right file when looking for an old build. I thought it would be great if I could preview the files directly in the Windows explorer window as one can do with common image files.

I knew from messing around with the LXF-file, that they were simply a zip-file with two files in it: A small PNG image of the build and a XML file with the data. So I knew that an image of the build already existed, ready to be used as a thumbnail for the file. Knowing that, I thought that it might be fairly easy to make Windows show this image in the Explorer window. I just needed to learn how.

I started to look around for possible solutions and I found an open source C# project that did just what I wanted to do (more more), SharpShell. It has a license that allowed me freely copy and modify the code so it suited me perfectly.

At first I constructed a handler that was made up with mostly SharpShell code. Once I got it working, I then cut out everything I didn’t need and rewrote anything I didn’t like. I also had to make a few improvements to their IStream wrapper (ComStream.cs). It could not handle calls to the Read method with the offset parameter set to anything other than zero and it did not release the IStream object when it was done with it. The first problem meant that the wrapper wouldn’t work with built in .net zip-file reader. The second problem would prevent an user from editing, moving and deleting a LXF-file for a minute or more after the Thumbnail was generated. (This was a few years ago so it is possible that latest version of SharpShell no longer have these issues)

The Installer was derived from SharpShell code in a similar way.

It was interesting to work on this code as it accesses parts that are written as so called “Unmanaged” code. This meant I was working with memory and pointers more similar to how it is done in C/C++. Something one generally don’t do when working with C#/.net code. It was a nice departure from my normal comfort zone with fully managed code.

Future

I don’t know when I’ll get back to this project, but it would be nice to add support for Bricklink’s Studio files to it. Those files are also disguised zip files with an image file inside them. So adding support for them should not be hard. Only major difference is that the Studio files needs to be unlocked with the password “soho0909” to read them.

This project might also be a good candidate for rewriting to C/C++ code if I ever want to learn working it C/C++ and Windows on a lower level.