Skip to main content

smlibpy 0.6.2 · python 3.10 – 3.15


smlibpy is a library for 3D modeling on the SMLib NURBS kernel, in Python, in JavaScript on WebAssembly and in three.js. It comes with an MCP server, so your agent can build parts too.

agent, look at smlibpy.classcad.ch and install the mcp

Your agent finds the steps in /llms.txt. If you only want the library: Python, WASM or three.js.

Or add it by handClaude Code · Claude Desktop · Codex · VS Code · Cursor · OpenCode

in a terminal

claude plugin marketplace add awv-informatik/smlibpy
claude plugin install smlibpy@smlibpy

reads STEP IGES USD DXFwrites STEP USD DXF SVG STL glTF.brep for OpenCASCADEMIT + Apache 2.0no account

An agent is told: agent, look at smlibpy.classcad.ch and install the mcp. It reads llms.txt and adds the smlibpy server, which runs with uvx and needs no account. In a new session it is asked for a pipe flange: a Ø120 × 12 mm plate with a Ø70 neck, 40 mm tall, bored Ø50, with eight Ø10 holes on a Ø95 circle. It reads the guides, revolves a half section, adds the holes, a fillet and a chamfer, checks the volume (157 979.7 mm³), looks at a snapshot of four views and saves flange.step. The session's live view comes up beside the conversation with the part in it, and the part is turned.

01Python

Your script builds the model. Each line creates a shape or changes it: combine solids, round edges, cut a pocket. The same API in Python, in JavaScript on WebAssembly and in three.js, or your agent writes the script. Hover over a line to see the part at that step.

pip install smlibpy
plate.pyline 3
  1. from smlibpy import *
  2. plate = Box(80, 60, 10)
  3. plate = plate.fillet(plate.edges().parallel_to(Z), 8)
  4. plate -= GridLocations(60, 40, 2, 2) * Cylinder(4, 10)
  5. plate -= Rectangle(30, 20).on(plate.faces().top()).extrude(-4)
  6. plate.export("plate.step")

Wheels for Linux, macOS and Windows, with the kernel compiled in. show() opens the part in your browser or a notebook, render() saves a PNG for scripts and CI. Getting started has more.

a box, centered on the origin48 000 mm³ · 6 faces

Python 3.10 – 3.15Linux macOS Windowsbuilds in 17 msSTEP with the exact geometry

02Features

213 features. Each drawing shows the call under it on a small example, built with smlibpy and drawn from the part it returned. Red is what the call made.

0 features

Parts

Solids from primitives, from sketches and from other solids, and faces moved or offset in place, on an imported part too. Every operation is a method and a function of the same name, and returns a new part; parts combine with +, - and &, or merge into one part of cells. Parts →

smlibpy or ClassCAD?

smlibpy builds a part once, from a script. A part that rebuilds when a value changes, with a feature history, constrained sketches and assemblies, is what ClassCAD is for. ClassCAD →

03How it works

Parts are B-reps with exact surfaces: planes, cylinders, cones, spheres, tori and NURBS. Volumes and areas are integrated over those surfaces, so they are accurate to about seven digits.

smlibpy checks what the kernel returns. If a fillet is too large for its edges, you get an error that tells you the largest size that fits. Where the kernel would give a wrong result, you get an error that says what to change: version 0.5 came out of a review of smlibpy against the kernel.

smlibpy reads and writes STEP itself and keeps the exact geometry. We check the reader against OpenCASCADE on more than 400 files from other CAD systems. OpenCASCADE’s own .brep files go both ways, for build123d, CadQuery and FreeCAD.

The MCP server runs the scripts of each session in a process of its own. If a script hangs or the kernel crashes, the server restarts that process and replays the session.

  1. Your scriptPython you write, or that an agent writes and runs through the MCP server.
  2. MCP serverRuns the scripts in a session per conversation, shows each live in Buerligons and renders pictures.
  3. smlibpyShapes, selections, features, result checks, and the readers and writers of its files.
  4. SMLibThe C++ kernel: topology, Booleans, fillets, offsets, sweeps and mass properties.

04Examples

Each one is a short script in the repository. The drawings and the numbers come from running those scripts.

05smlibpy and ClassCAD

Both use SMLib. ClassCAD has been built on it for twenty years.

ClassCAD

A CAD system.

ClassCAD stores how a part was made. Sketches have constraints and dimensions, and features reference the faces and edges they were built on. When you change a dimension, ClassCAD recalculates only what depends on it.

It also has assemblies with mates, a PDM for versions and releases, and Buerligons, the CAD app in the browser.

history graph · references · constrained sketches · assemblies · PDM · reuse · incremental recalculation

smlibpy

A library.

In smlibpy, a part is what your script produces. Nothing is stored besides the script. To change the part, you edit the script and run it again, which takes milliseconds for most parts.

That works well for variants, batch jobs, notebooks, CI checks and agents. It is also the quickest way to try out SMLib.

scripts · exact geometry · STEP in and out · notebooks · agents

STEP works between the two: a part made with smlibpy opens in ClassCAD as a solid. An agent with both MCP servers can save a part with smlibpy and load it into Buerligons.

06SMLib and OpenCASCADE

OpenCASCADE has been the open-source B-rep kernel for more than twenty years. Now SMLib is open source too. This is how they compare.

SMLibOpenCASCADE
Where fromA commercial NURBS kernel that has been in production use for decades; ClassCAD has used it for twenty years.Matra Datavision’s CAS.CADE, open source since 1999 and developed by Open Cascade SAS.
LicenseApache 2.0: you can use, change and ship it, also in closed-source products.LGPL 2.1 with an exception for linking; changes to OCCT itself stay open.
ScopeA modeling kernel: geometry, topology, Booleans, blends, offsets, sweeps, tessellation, healing.A platform: the kernel plus data exchange, meshing, visualization and an application framework.
GeometryNURBS throughout; planes, cylinders and the other analytic surfaces stay analytic.Analytic surfaces, B-splines, offsets and more, each with its own algorithms.
FilletsCircular, variable and curvature-continuous (G2, G3) blends.Rolling-ball fillets, tangent-continuous, constant or variable.
Pythonsmlibpy, and SMLib’s own low-level bindings.pythonOCC and OCP, with CadQuery, build123d and others on top.

07Questions

Is it free?
Yes. smlibpy is MIT licensed and SMLib comes with it under Apache 2.0. Both allow commercial use.
Do I need a GPU, a CAD system or an account?
No. It is a Python package with the kernel compiled in. Pictures are rendered in software, and the viewer is a page in your browser.
How exact is it?
The geometry is exact. Triangles only come in when you export a mesh. Volumes, areas and centers are accurate to about seven digits by default, and mass_properties(accuracy=…) can go further.
Who makes it?
AWV Informatik in St. Gallen, the people behind ClassCAD, buerli and Buerligons. We have built CAD on SMLib for twenty years.
Does it work with build123d, CadQuery or FreeCAD?
Yes, through files: STEP, and OpenCASCADE’s own .brep, which smlibpy reads and writes with the exact geometry.
Is it ready?
It is at version 0.6. Modeling, measuring, drawings, text and the files work and are tested. 0.5 came out of a review against the kernel, and 0.6 made the API even: every operation is a method and a function of the same name. Assemblies with constraints are not part of it: that is what ClassCAD is for.