Skip to content

build123d

Python based boundary representation (BREP) modelling framework for 2d/3d modelling.

  • Built on the Open Cascade geometric kernel
  • Generated from faults of CADQuery
    • Somewhat restricted Fluent API (method chaining)
    • Replaced with full python toolbox

Rendering

Use OCP CAD Viewer

  • OCP = OCCT-powered (referring to the underlying Open CASCADE Technology).

How to run:

  1. via vscode extension
  2. via terminal:

Create a new project

$ mkdir <project-name>
$ cd <project-name>
$ uv init
$ mv main.py <project-name>.py
$ uv venv .venv

Activate existing project

$ source .venv/bin/activate
$ python -m ocp_vscode
$ python -m ocp_vscode --theme dark
$ python box_generate.py # need a 2nd terminal or tmux

This will start a Flask server and the viewer can be reached under

http://127.0.0.1/<port-number>/viewer

OCP viewer standalone

Coding Structure

By default, there is no units. When exporting to external formats like STL or STEP the units are assumed to be millimeters (mm).

There are two types of way to design, build mode & algebra mode.

Build Mode

with BuildPart() as my_part:
    ...
    with BuildSketch() as my_sketch:
        ...
        with BuildLine() as my_line:
            ...
        ...
    ...

Code breakdown:

  • BuildPart: builds volume
  • BuildSketch: creates area
  • BuildLine: creates lines

Algebra Mode

Animations

https://github.com/GarryBGoode/gggears

You can see the animation in the viewer w/ this code:

import numpy as np

animation = Animation(p.part)
times = np.linspace(0, 2, 11) # 2 seconds split in 0.2 intervals
values = np.linspace(0, 360, 11) # as many positions as times
animation.add_track(f"/Group", "rz", times, values) # animate the group 

show(p)
animation.animate(1)

I never toyed with that feature myself, but YACV internally uses the GLTF format, which is a common one supporting animations. The documentation for YACV is nearly non-existant, but I guess, it relies on model-viewer for this feature, so maybe their documentation may help.

From Mac on Discord CadQuery, Build123d server (wants to know about it after test)

Mobile Sandbox

There are wasm ports that work on mobile

b123d

CAD Viewer

Social

.gitignore