Skip to main content

lib3mf

![Build Status] Documentation Status Version 2.3.2 Supported platforms Simplified BSD License codecov

lib3mf is a C++ implementation of the 3D Manufacturing Format file standard.

It provides 3MF reading and writing capabilities, as well as conversion and validation tools for input and output data. lib3mf runs on Windows, Linux and MacOS and offers a clean and easy-to-use API in various programming languages to speed up the development and keep integration costs at a minimum.

As 3MF shall become an universal 3D Printing standard, its quick adoption is very important. This library shall lower all barriers of adoption to any possible user, let it be software providers, hardware providers, service providers or middleware tools.

The specification can be downloaded at http://3mf.io/specification/.

Example (Create Cube)

import lib3mf
from lib3mf import get_wrapper

# Get version
def get_version(wrapper):
    major, minor, micro = wrapper.GetLibraryVersion()
    print("Lib3MF version: {:d}.{:d}.{:d}".format(major, minor, micro), end="")
    hasInfo, prereleaseinfo = wrapper.GetPrereleaseInformation()
    if hasInfo:
        print("-" + prereleaseinfo, end="")
    hasInfo, buildinfo = wrapper.GetBuildInformation()
    if hasInfo:
        print("+" + buildinfo, end="")
    print("")


# Create vertex in a mesh
def create_vertex(_mesh, x, y, z):
    position = lib3mf.Position()
    position.Coordinates[0] = float(x)
    position.Coordinates[1] = float(y)
    position.Coordinates[2] = float(z)
    _mesh.AddVertex(position)
    return position


# Add triangle in a mesh
def add_triangle(_mesh, p1, p2, p3):
    triangle = lib3mf.Triangle()
    triangle.Indices[0] = p1
    triangle.Indices[1] = p2
    triangle.Indices[2] = p3
    _mesh.AddTriangle(triangle)
    return triangle


# Get a wrapper object
wrapper = get_wrapper()

# Check version always
get_version(wrapper)

# Create a model
model = wrapper.CreateModel()
mesh_object = model.AddMeshObject()
mesh_object.SetName("Box")

# Define the size of the cube
fSizeX, fSizeY, fSizeZ = 100.0, 200.0, 300.0

# Create vertices
vertices = [
    create_vertex(mesh_object, 0, 0, 0),
    create_vertex(mesh_object, fSizeX, 0, 0),
    create_vertex(mesh_object, fSizeX, fSizeY, 0),
    create_vertex(mesh_object, 0, fSizeY, 0),
    create_vertex(mesh_object, 0, 0, fSizeZ),
    create_vertex(mesh_object, fSizeX, 0, fSizeZ),
    create_vertex(mesh_object, fSizeX, fSizeY, fSizeZ),
    create_vertex(mesh_object, 0, fSizeY, fSizeZ)
]

# Define triangles by vertices indices
triangle_indices = [
    (2, 1, 0), (0, 3, 2), (4, 5, 6), (6, 7, 4),
    (0, 1, 5), (5, 4, 0), (2, 3, 7), (7, 6, 2),
    (1, 2, 6), (6, 5, 1), (3, 0, 4), (4, 7, 3)
]

# Create triangles
triangles = []
for v0, v1, v2 in triangle_indices:
    triangles.append(add_triangle(mesh_object, v0, v1, v2))

# Set geometry to the mesh object after creating vertices and triangles
mesh_object.SetGeometry(vertices, triangles)

# Add build item with an identity transform
model.AddBuildItem(mesh_object, wrapper.GetIdentityTransform())

# Save the model to a 3MF file
writer = model.QueryWriter("3mf")
writer.WriteToFile("cube.3mf")

Documentation

lib3mf's documentation is available on https://lib3mf.readthedocs.io.

Obtaining lib3mf

Simply download the precompiled binary SDK https://github.com/3MFConsortium/lib3mf/releases.

Using lib3mf

Allthough the different language bindings are kept as similar as possible, the usage of lib3mf still depends your programming language.

You are best-off starting with one of the examples distributed in the SDK or with this minimal example in C++.

Contributing

lib3mf is an open source project and supported by the 3MF Consortium.

Contributions are welcome and we are always looking for people that improve the implementation of the specification and extensions of 3MF. Have a look at the contributor's guide for details. This page also contains a section about building lib3mf from source or obtaining nightly snapshot builds.

Licenses and third party code

lib3mf is released under the BSD license. The library contains code of the following third parties:

  1. libzip 1.10.1, https://libzip.org/license/
  2. zlib 1.3.1, http://www.zlib.net/zlib_license.html
  3. cpp-base64 2.rc.08, https://github.com/ReneNyffenegger/cpp-base64/blob/master/LICENSE
  4. fast-float v6.0.0, https://github.com/fastfloat/fast_float/tree/v6.0.0?tab=License-3-ov-file

In addition, the automated tests of lib3mf make uses of LibReSSL 3.8.2, License and googletest 1.14.0 License.

Metadata

Release files for lib3mf 2.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for lib3mf 2.5.0
File Interpreter ABI Platform
lib3mf-2.5.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
lib3mf-2.5.0-py3-none-manylinux2014_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details
lib3mf-2.5.0-py3-none-macosx_10_9_universal2.whl Python 3 none macOS 10.9+ universal2 (ARM64, x86-64) Details

Total release size: 4.6 MB

Release files / lib3mf-2.5.0-py3-none-win_amd64.whl

Download URL lib3mf-2.5.0-py3-none-win_amd64.whl
Size 857.6 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
e378470855d634708c6ae7f2f2c6fcd89e4996350de86020849e7b2d51ffe6ac
BLAKE2b-256 checksum
How to use checksums
a9b37a844247dfa1f0b24de6fa0425afb808dd1feeef2d05d6335170433c1071
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.19

Release files / lib3mf-2.5.0-py3-none-manylinux2014_x86_64.whl

Download URL lib3mf-2.5.0-py3-none-manylinux2014_x86_64.whl
Size 1.6 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
b4c00033c47cfeac93b7daa069fb46e8dea4391d5522b79cd6e9f6af75e33013
BLAKE2b-256 checksum
How to use checksums
88838b987ba95ac0ed9cc7e9c407a579bf43eff6349b1792b4a66c992ce4f76b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.19

Release files / lib3mf-2.5.0-py3-none-macosx_10_9_universal2.whl

Download URL lib3mf-2.5.0-py3-none-macosx_10_9_universal2.whl
Size 2.2 MB
Tags Python 3 macOS 10.9+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
f7dc57ea22214fa92dac728ba66e58c4b24b775d467888262a820338d7d84145
BLAKE2b-256 checksum
How to use checksums
048747504d69f0f36841670d12ce3fe1668025bad74d83ed361ead378f626fed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.19

Release history Release notifications | RSS feed

This release

2.5.0 This release

3 release files

2.4.1

3 release files

2.3.4

3 release files

2.3.3

1 release file

2.3.2

1 release file

2.3.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page