Convert a 3D object into a brick structure.
Project description
mesh2brick
mesh2brick is a utility package for converting an input mesh file into a brick structure in JSON, text, or LDraw
format.
Usage
Standalone project
To use as a standalone project, first install the package manager uv. Then, clone the repository:
git clone https://github.com/K1ngHungry/mesh2brick.git
cd mesh2brick
Finally, run the mesh2brick script with the following command. uv automatically installs all dependencies upon
running.
uv run mesh2brick [INPUT_MESH_FILE] [OUTPUT_BRICK_FILE]
The [INPUT_MESH_FILE] can be any mesh format (.obj, .glb, etc.).
The [OUTPUT_BRICK_FILE] should end in .json, .txt, or .ldr to specify one of the following three output formats:
- JSON. The output JSON maps a 1-based sequence number to each brick. Each brick has the following keys:
brick_id: A number indicating the brick type. Seebrick_library.jsonfor a list of brick types.x,y,z: The coordinates of the brick in 3D space.type:0for a regular brick/plate,1for a slope brick.rotation:0–3, indicating the orientation of the brick (90° increments).
- Text. The output text file is a list of bricks, one per line, with the following format:
T{type} {l}x{w}x{h} R{rotation} (x,y,z), wheretypeis the brick type (0=brick/plate,1=slope),l,w,hare the brick dimensions along the x-, y-, and z-axes,rotationis the orientation (0–3), and(x,y,z)are the coordinates of the brick in 3D space. - LDraw. The output LDraw file can be used directly with LDraw-compatible software to visualize the brick structure.
Run uv run mesh2brick --help to see all available options.
Python package
To install mesh2brick as a package in an existing project, run:
pip install mesh2brick
if using pip, or
uv add mesh2brick
if using uv.
Then, you can use the mesh2brick module in your Python code:
from mesh2brick import Mesh2Brick
input_file = "path/to/your/input_mesh.obj"
mesh2brick = Mesh2Brick()
output_bricks = mesh2brick(input_file)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mesh2brick-0.1.0.tar.gz.
File metadata
- Download URL: mesh2brick-0.1.0.tar.gz
- Upload date:
- Size: 122.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ace739e720c5368206bd20a8cfd7b49d72e3d5c3713708399e61b6af916660f
|
|
| MD5 |
c7bfd0c7f2166a88d00aeda16a1a2705
|
|
| BLAKE2b-256 |
a596b61b60abf1e6cd4f0d2c7ee77e2f7fa1075908c657a5bc419337e2fcdabc
|
File details
Details for the file mesh2brick-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mesh2brick-0.1.0-py3-none-any.whl
- Upload date:
- Size: 39.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c72b5f79658cc9bdf265777cbe33c7c5c6389eda9bde14efd20e842e55c25abf
|
|
| MD5 |
3c7435b92436a1af3e55db00a141b825
|
|
| BLAKE2b-256 |
1cd0c8fc293602d8516fa6a7e663cb748b4660873eef2989b6397b8f361071f6
|