Dat2QP: LDraw to Quad2Dat converter
Dat2QP is a tool written in C++ by J.C. Tchang. It allows to convert a LDraw file into a Quad2Dat one.
Purpose of the program
Quad2Dat is a program written by Chris Alano, allowing creation of patterns for LDraw parts. Despite many imperfections and crashes, this tool remains the best in its category. Thanks, Chris. You may download it here.
The purpose of Dat2QP tool is to allow recovering existing LDraw patterns to easily modify or complete them using Quad2Dat.
Dat2QP converts 3D quads or triangles to 2D (projection on a plane) and writes the result using Quad2Dat file format (.qp). You may choose projection direction along X, Y (default) or Z axis.
Another use of Dat2QP is to allow use of tools outside Quad2Dat, such as :
Dat2QP package, including Windows program, source file and this documentation.
No installation is required, just unzip the archive and copy the executable file (dat2qp.exe) in a directory. For example, I use folder c:\lego\dat2qp.
Note: Macintosh version (universal binary) courtesy of Jim DeVona.
Creation of input file
Your input file should contain the facets to be processed, that is to say triangles (type 3) and/or quads (type 4). Dat2QP doesn't manage primitives (type 1) that must be inlined by a tool such as LDraw Design Pad (LDDP).
Place this file in the install folder of Dat2QP, e.g. in c:\lego\dat2qp.
Converting with Dat2QP
Open a "Command prompt" window (DOS box on older
systems), then go to Dat2QP install folder: type the
command cd c:\lego\dat2qp, or if you
are not a command prompt wizard, just type cd
followed by a space character, then from a Windows explorer
opened on Dat2QP install folder, drag and drop the folder
icon from the address bar onto the command prompt window, select
this window and hit
Type in the command:
Using the output file with Quad2Dat
You may then use the output file, test1.qp for example, with Quad2Dat.
Note : if you get this error message when opening the file in Quad2Dat: "Run-time error '13': Type mismatch", your system is setup with a comma "," instead of dot "." as fractional part separator. Use your favorite text editor to replace all commas "," with dots ".".
The default template used by the conversion is the 1x6x5 brick. If the facets converted with Dat2QP do not fit the template, just hide it in Quad2Dat options: View / Options..., than in "Display" tab, uncheck "Template".
See Quad2Dat manual for more information.
Warning: SAVE OFTEN under different names when using Quad2Dat, because it crashes in many case with lost of the data previously recorded.
Integration of Dat2QP into LDraw Design Pad
You may launch Dat2QP from LDraw
Design Pad after creating the 3 .bat files below:
Note: The files must be placed in the folder indicated in "Path & Filename:" field of the dialog boxes below. In these example it is the LDDP Plugins folder
Then setup LDDP as follows:
Once properly configured, you may launch Dat2QP within LDDP
from the menu Process/External Programs/User Defined Program,
or using "User Defined Program" icon in the "External
Conversion result is in file dat2qp-x_result.qp, or dat2qp-y_result.qp, or dat2qp-z_result.qp, placed in the same directory as the original file.
Intégration de Dat2QP dans LETGUI
You may launch Dat2QP in a way more user-friendly than command line. That's the purpose of LETGUI, created by Michael Heidemann.
Tutorial: a concrete example
Browsing through LDraw parts library for the 1x1 brick with "6" I realize that this brick exists in two versions, one of them (3005-6.DAT) fits my needs.
Looking at this part with LDView, I see that this part is not perfect. Facets overlap, and there is a gap. I decide to improve it.
First I replace all faces and stud with subpart s\3005s01.dat
Then I convert the Ldraw file to Quad2dat using -z projection direction
A first glance with Quad2dat show two overlapping areas, and a missing triangle.
I suppress wrong facets and rebuild missing parts with quads and triangles of the right color.
Now we can go further and suppress T junctions, always with
the same method: delete facets and recreate them right.
This is not perfect, but looks like a bit more to right side photo. I didn't try to get exactly the same character height as there was many font variants used on this part year after year.
After a LDraw export and replacing the result in complete part file, we get our updated part.
(c) J.C. Tchang - 2008
French Manual: J.C. Tchang. English translation: Philo
Free for any non-commercial use. :-)