libcad

libcad

CAD reimagined

libcad introduces a novel concept: CAD as a library. Built from the ground up for ease of scripting and integration, libcad can be used for any application, from custom design environments to lightweight web rendering and design automation.

Why libcad?

Completely Free

libcad is provided under the permissive MIT license, allowing use for any purpose, commercial or non-commercial.

Cross-Platform

libcad runs on all major platforms, including Windows, macOS, Linux, Web and mobile.

Self-Contained

libcad depends only on standard utilities provided by your OS. All other dependencies are embedded directly into the library itself.

Lightweight

The entire library is built into a single file that measures less than 10MB.

Scriptable

libcad is built with scripting in mind, enabling easy integration into any application or workflow.

Multi-Language

libcad itself is written in C, but bindings are available for C++, JavaScript and Python.

libcad in Practice

Example 1: Creating and exporting a cube to STL

import cad

# create a new document
document = cad.new_document("cube")

# create a sketch and add a centered rectangle to it (100x100mm)
sketch = document.add_sketch()
rectangle = sketch.add_center_rect(0, 0, 100, 100)

# extrude the rectangle into a cube with a height of 100mm
cube = rectangle.extrude(100)

# export the cube as an STL file
cube.export_stl("cube.stl")

Example 2: Visualizing a model

import cad

# load a document
document = cad.load_document("cube")

# create a view and add a callback to rotate the camera over time
view = document.create_view()
view.add_update_callback(
    lambda time, camera: camera.set_rotation(0, 0, math.sin(time) * 360)
)

# show the view in a window
view.show()