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 mcpYour 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
01
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- 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")
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.
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 →
- 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) - Sector
Cylinder(r, h, arc_size=270) - Annular sector
AnnularSector(r1, r2, h, 120) - Pyramid
Pyramid(l, w, h) - Union
a + b - Difference
a - b - Intersection
a & b - Cells
merge(a, b). cells( ) - Extrude
extrude(sketch, h) - Tapered extrude
extrude(…, taper=12) - Taper, round corners
extrude(…, corners='round') - Revolve
revolve(sketch, Z, 270) - Swing
swing(profile, outline) - 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)) - Radius law
fillet(edge, {0: 2, 0. 5: 9, 1: 2}) - Set-back corner
fillet(edges, r, setback=16) - G2 fillet
fillet(…, continuity='G2') - Chamfer
part.chamfer( edges, d) - Chamfer, two lengths
chamfer(…, 12, length2=4) - Chamfer at an angle
chamfer(…, 10, angle=30) - Chamfered circles
chamfer(circles, d) - Shell
part.shell( t, faces) - Shell, thicker walls
shell(…, walls=[( floor, 12)]) - Offset
offset(part, d) - Rounded offset
part.offset( d, corners='round') - Draft
part.draft( faces, 8, Plane. XY) - Mirror
mirror(part, Plane. YZ) - Split
split(part, plane) - Split by a sheet
part.split( sheet, keep='both') - Imprint
part.imprint( curves, direction) - Section
section(part, plane) - Move faces
part.move_faces( faces, by) - Offset faces
part.offset_faces( faces, d) - 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
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.
- Your scriptPython you write, or that an agent writes and runs through the MCP server.
- MCP serverRuns the scripts in a session per conversation, shows each live in Buerligons and renders pictures.
- smlibpyShapes, selections, features, result checks, and the readers and writers of its files.
- 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.
Pipe flange
A revolved section, eight bolt holes, a fillet and a chamfer.
157 979.7 mm³ · 17 faces · 113 ms
Mounting bracket
An L-profile with rounded edges, holes and countersinks.
31 287.1 mm³ · 19 faces · 28 ms
Spur gear
Involute teeth, a bore and a keyway.
20 291.1 mm³ · 246 faces · 1197 ms
The bottle
The classic OpenCASCADE tutorial part: a filleted body with a neck, shelled to 0.6 mm.
6 946 mm³ · 56 faces · 289 ms
Enclosure
A shelled box with screw bosses, and a lid with a lip.
2 parts · 74 faces · 151 ms
Spring
A circle swept along a helix.
2 170.1 mm³ · 3 faces · 305 ms
Pipe
A bent pipe with two flanges, swept along its path.
29 205.7 mm³ · 21 faces · 110 ms
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.
| 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. |
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.