smlibpy 0.1·python 3.10 – 3.14
smlibpy is a Python library for 3D modeling on the SMLib NURBS kernel. It comes with an MCP server, so your agent can build parts too.
agent, look at smlibpy.classcad.ch and install the mcpYour agent finds the steps in /llms.txt. If you only want the library: pip install smlibpy.
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 USD DXFwrites STEP USD DXF STL glTFMIT + Apache 2.0no account
01Python
Your script builds the model. Each line creates a shape or changes it: combine solids with + and −, round edges, cut a pocket. Hover over a line to see the part at that step.
- from smlibpy import *
- plate = Box(80, 60, 10)
- plate = plate.fillet(plate.edges().parallel_to(Z), 8)
- plate -= GridLocations(60, 40, 2, 2) * Cylinder(4, 10)
- plate -= Rectangle(30, 20).on(plate.faces().top()).extrude(-4)
- plate.export("plate.step")
builds in 22 msvolume 43 040 mm³19 faces · validSTEP with the exact geometry
02Features
173 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. Every call returns a new part, and 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 →
- Box
Box(l, w, h) - Cylinder
Cylinder(r, h) - Cone
Cone(r1, r2, h) - Sphere
Sphere(r) - Torus
Torus(R, r) - Wedge
Wedge(l, w, h, top) - Union
a + b - Difference
a - b - Intersection
a & b - Cells
merge(a, b). cells( ) - Extrude
extrude(sketch, h) - Tapered extrude
extrude(…, taper=12) - Revolve
revolve(sketch, Z, 270) - Loft
loft([a, b]) - Sweep
sweep(sketch, path) - Sweep along a helix
sweep(c, Helix( …)) - Fillet
part.fillet( edges, r) - Variable fillet
fillet(edge, ( r1, r2)) - G2 fillet
fillet(…, continuity='G2') - Chamfer
part.chamfer( edges, d) - Shell
part.shell( t, faces) - Offset
offset(part, d) - Draft
part.draft( faces, 8, Plane. XY) - Mirror
mirror(part, Plane. YZ) - Split
split(part, plane) - Section
section(part, plane) - Hole
Hole(r, depth) - Counterbore
CounterBoreHole(…) - Countersink
CounterSinkHole(…) - Locations
Locations(…) * part - Grid
GridLocations(…) * part - Polar
PolarLocations(r, n) * part - Hexagonal
HexLocations(…) * part - Translate
part.translate( x, y, z) - Rotate
part.rotate( Z, a) - Scale
part.scale( k) Key
- what the call made
- hidden
- taken away, or moved
- the profile it starts from
- an axis, a path
- a move
03Install
There are wheels for Linux, macOS and Windows, for Python 3.10 to 3.14. The kernel is compiled in, so there is nothing else to set up.
In Python
- $ pip install smlibpy
- from smlibpy import *
- part = Box(40, 30, 10) - Cylinder(6, 20)
- print(part.volume)
- part.export("part.step")
- show(part)
show() opens the part in your browser, or inline in a notebook. render() saves a PNG instead, for scripts and CI. Getting started has more.
For your agent
- $ claude plugin marketplace add awv-informatik/smlibpy
- $ claude plugin install smlibpy@smlibpy
The plugin installs the MCP server and a skill with a guide for every function. The server runs on your machine with uvx and shows the session in Buerligons, the ClassCAD app, after every script; what you select there reaches the agent. Setup for other hosts is at the top of this page and in the docs.
04JavaScript
smlibwasm is smlibpy for JavaScript and TypeScript: the same API on the same kernel, compiled to WebAssembly. It runs in the browser and in Node, without a server and without dependencies.
Install it with npm
- $ npm install @classcad/smlibwasm
- import { Box, Cylinder, toStep } from '@classcad/smlibwasm'
- const part = Box(40, 30, 10).cut(Cylinder(6, 20))
- console.log(part.volume)
- const step = toStep(part)
Names are camelCase, and operators are methods: a.cut(b) for Python’s a - b. The JavaScript docs have the whole API in TypeScript.
1.8 MB over the wire
- The kernel, smlibwasm.wasm
- 1.5 MB
- The library
- 0.21 MB
- The font of Text
- 46 kB
- The loader, smlibwasm.mjs
- 22 kB
- Together
- 1.8 MB
Compressed with brotli, as web servers send it. Browsers cache the kernel, so it loads once. Importing the package waits for the kernel; every call after that is synchronous.
05How 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.
smlibpy reads and writes STEP itself and keeps the exact geometry. We compared the reader with OpenCASCADE on 430 files.
The MCP server runs scripts in a separate process. If a script hangs or the kernel crashes, the server restarts it and replays the session.
- Your scriptPython you write, or that an agent writes and runs through the MCP server.
- MCP serverRuns the scripts, keeps the session, shows it live in Buerligons and renders pictures.
- smlibpyShapes, selections, features, result checks, and the STEP reader and writer.
- SMLibThe C++ kernel: topology, Booleans, fillets, offsets, sweeps and mass properties.
06Examples
Each one is a short script in the repository. The drawings and the numbers come from running those scripts.
Pipe flange
A revolved section, eight bolt holes, a fillet and a chamfer.
157 979.5 mm³ · 17 faces · 129 ms
Mounting bracket
An L-profile with rounded edges, holes and countersinks.
31 287.1 mm³ · 19 faces · 27 ms
Spur gear
Involute teeth, a bore and a keyway.
20 291.1 mm³ · 246 faces · 1532 ms
The bottle
The classic OpenCASCADE tutorial part: a filleted body with a neck, shelled to 0.6 mm.
6 946 mm³ · 56 faces · 272 ms
Enclosure
A shelled box with screw bosses, and a lid with a lip.
2 parts · 74 faces · 122 ms
Spring
A circle swept along a helix.
2 170.1 mm³ · 3 faces · 157 ms
Pipe
A bent pipe with two flanges, swept along its path.
29 205.7 mm³ · 21 faces · 180 ms
07smlibpy 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.
08SMLib 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.
| SMLib | OpenCASCADE | |
|---|---|---|
| Where from | A 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. |
| License | Apache 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. |
| Scope | A modeling kernel: geometry, topology, Booleans, blends, offsets, sweeps, tessellation, healing. | A platform: the kernel plus data exchange, meshing, visualization and an application framework. |
| Geometry | NURBS throughout; planes, cylinders and the other analytic surfaces stay analytic. | Analytic surfaces, B-splines, offsets and more, each with its own algorithms. |
| Fillets | Circular, variable and curvature-continuous (G2, G3) blends. | Rolling-ball fillets, tangent-continuous, constant or variable. |
| Python | smlibpy, and SMLib’s own low-level bindings. | pythonOCC and OCP, with CadQuery, build123d and others on top. |
09Questions
- 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.
- Is it ready?
- It is new, version 0.1. Modeling, measuring and STEP work and are tested. Assemblies with constraints, 2D drawings and text are not there yet.