LDMerge is a console program for merging and unmerging the contents of multiple LDraw directory structures. Multiple part libraries may be used to manage unofficial parts. Some LDraw-compatible programs support this concept, but others do not. By providing a way to temporarily combine several part libraries, this utility facilitates those tools which recognize only a single LDraw directory — without forcing you to adopt the same convention.

Unlike its predecessor LDLink, LDMerge does not rely on symbolic links.


LDMerge performs two actions: merge and unmerge.

Both actions are applied to a target library. Merging adds parts to the target libary and unmerging removes those parts from the target library.

A source library provides the parts that are merged. More than one source can be merged into the same target. Parts from all sources or from one particular source can be unmerged.

An index file records the source of each merged part.

LDMerge considers an LDraw part library to be a directory containing the subdirectories parts, parts/s, p, and p/48. Files of any type within these subdirectories are considered parts. Other files and folders in the library but not within those specific subdirectories are ignored.


LDMerge accepts command line arguments corresponding to each of the key terms introduced above.

ldmerge merge|unmerge
        [-target LDRAWDIR]
        [-source LDRAWDIR|all]
        [-index FILE]
        [-mode copy|move|link]
        [-flag verbose]

The first argument is required and specifies the action: merge or unmerge.

If -target is not specified, the value of the LDRAWDIR environment variable is used.

If -source is not specified, it is assumed to be the target’s Unofficial subdirectory. (LDView can automatically download unofficial parts to this location.) The special all source is meaningful only when unmerging.

If -index is not specified, the file ldmerge.ldr in the target directory is used.

The -mode option allows you to specify how parts are merged. By default, part files are copied from the source to the target. If the move mode is used, the source files themselves are moved to the target directory. They are returned to the source directory when unmerged. The link mode creates symbolic links (on Mac OS X or Linux) or hard links (on Windows NTFS systems) to the source files. Moving or linking can be faster, but copying may present the fewest complications. It is not necessary to specify a -mode when unmerging.

Specify -flag verbose to print a line reporting each merge or unmerge operation.


To merge unofficial parts downloaded by LDView with the rest of your part library, the following command may be sufficient:

ldmerge merge

That copies each part from LDRAWDIR/Unofficial to the corresponding subdirectories of LDRAWDIR, and records the merges in LDRAWDIR/ldmerge.ldr. The default merge can be reversed with the following command:

ldmerge unmerge

This merge command moves the actual source files to the target library:

ldmerge merge -source /Custom/LDraw -mode move

To restore the main library to its original state by removing all merged files, use this command (merged files will be returned to their original location if they were moved):

ldmerge unmerge -source all

A merge can be made permanent by removing the relevant lines from the merge index.

LDMerge will not replace parts in the target library unless the existing merge index indicates that they came from the current source library. Part conflicts and other recognized exceptions are reported; merging or unmerging proceeds if possible. Errors copying, moving, or linking files cause the program to stop.

Parts are identified by filename. File contents are not examined.

Index Format

The index records are formatted as LDraw meta commands. At present, this choice of format is arbitrary, but it may facilitate interesting possibilities in the future.

0 !LDMERGE /Target/LDraw/parts/part.dat SOURCE /Source/LDraw/parts/part.dat

Each record documents a merged part in the target library. The path to this part is stated after the !LDMERGE token. Subsequent parameters may appear in any order and are interpreted as “PARAMETER value” pairs. Presently only the SOURCE parameter is used; it specifies the part’s original location.

Records without SOURCE parameters are valid. They effectively “reserve” parts. If present, the part cannot be removed; if not present, the part cannot be added.

Index lines that cannot be interpreted as LDMerge records are ignored but retained. They appear before all valid records in the updated index.

Paths may contain whitespace, in which case they appear quoted in curly braces.


LDMerge is currently available in three forms:

The source code may be extracted from any version with SDX. LDMerge is localizable; see en_us_example.msg for more details. LDMerge is public domain software.



Posted on Monday, October 1st, 2007. Tags: , .