https://github.com/djeedai/weldr
A Rust library and command-line tool to manage LDraw files (.ldr)
https://github.com/djeedai/weldr
command-line-tool ldraw lego parser rust rust-library
Last synced: 9 days ago
JSON representation
A Rust library and command-line tool to manage LDraw files (.ldr)
- Host: GitHub
- URL: https://github.com/djeedai/weldr
- Owner: djeedai
- License: apache-2.0
- Created: 2020-11-06T17:49:30.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-05-11T21:55:40.000Z (over 1 year ago)
- Last Synced: 2025-09-21T19:06:26.848Z (23 days ago)
- Topics: command-line-tool, ldraw, lego, parser, rust, rust-library
- Language: Rust
- Homepage: https://crates.io/crates/weldr
- Size: 186 KB
- Stars: 15
- Watchers: 2
- Forks: 4
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE2
Awesome Lists containing this project
README
# 👨🏭 weldr, the link between your favorite building blocks and Rust 🧱
[](https://github.com/djeedai/weldr#license)
[](https://github.com/djeedai/weldr/actions?query=workflow%3ACI)
[](https://coveralls.io/github/djeedai/weldr?branch=main)
**weldr** is a Rust library and command-line tool to manipulate [LDraw](https://www.ldraw.org/) files ([format specification](https://www.ldraw.org/article/218.html)), which are files describing 3D models of [LEGO®](http://www.lego.com)* pieces.
This repository is a Cargo workspace composed of the following packages:
| Package | Version | Description | Path |
|---|---|---|---|
| [📦 `weldr`](https://crates.io/crates/weldr) | [](https://crates.io/crates/weldr) | The weldr Rust library | [`lib/`](./lib) |
| [📦 `weldr-bin`](https://crates.io/crates/weldr-bin) | [](https://crates.io/crates/weldr-bin) | The ⚙ `weldr` command-line tool | [`bin/weldr/`](./bin/weldr) |## Library
The `weldr` library allows building command-line tools and applications leveraging [the fantastic database of pieces](https://library.ldraw.org/) contributed by the LDraw community.
Parse the content of a single LDraw file containing 2 commands:
```rust
use weldr::*;#[test]
fn test_weldr() {
let cmd0 = CommandType::Comment(
CommentCmd{ text: "this is a comment".to_string() }
);
let cmd1 = CommandType::Line(LineCmd{
color: 16,
vertices: [
Vec3{ x: 0.0, y: 0.0, z: 0.0 },
Vec3{ x: 1.0, y: 1.0, z: 1.0 }
]
});
assert_eq!(
parse_raw(b"0 this is a comment\n2 16 0 0 0 1 1 1"),
vec![cmd0, cmd1]
);
}
```## Command-line tool
The ⚙ `weldr` command-line tool is an executable to manipulate LDraw files and convert them to other formats (currently: glTF 2.0 only).
Convert an LDraw file to a glTF 2.0 file:
```shell
weldr convert gltf 5-8cyli.dat --output 5-8cyli.gltf
```The format is:
```shell
weldr
```You can get the list of commands with `weldr --help`. Currently only the `convert` command is implemented for the `gltf` (glTF 2.0) format.
```shell
weldr convert [OPTIONS] gltf
```The official LDraw catalog of parts is available at . When using it, use the `--catalog-path` to specify the location where it was downloaded, to allow ⚙ `weldr` to resolve files and all their sub-file references. By default the current working directory is used.
## Copyrights
LDraw™ is a trademark owned and licensed by the Estate of James Jessiman, which does not sponsor, endorse, or authorize this project.
*LEGO® is a registered trademark of the LEGO Group, which does not sponsor, endorse, or authorize this project.
## License
Licensed under either of
- Apache License, Version 2.0, ([LICENSE-APACHE2](LICENSE-APACHE2) or )
- MIT license ([LICENSE-MIT](LICENSE-MIT) or )at your option.
## Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license,
shall be dual licensed as above, without any additional terms or conditions.