### Import smlibpy namespace Source: https://github.com/awv-informatik/smlibpy/blob/main/docs/getting-started.md Everything is in one namespace, so a wildcard import brings in all classes and functions. ```python from smlibpy import * ``` -------------------------------- ### Build smlibpy from source for development Source: https://github.com/awv-informatik/smlibpy/blob/main/docs/getting-started.md Clone the repository with its submodule, build in place, and put src on the Python path. Requires pybind11, numpy, CMake, and a C++17 compiler. ```bash git clone --recursive https://github.com/awv-informatik/smlibpy cd smlibpy pip install pybind11 numpy cmake -S . -B build -G Ninja -Dpybind11_DIR="$(python -m pybind11 --cmakedir)" \ -DPython_EXECUTABLE="$(which python)" cmake --build build export PYTHONPATH=$PWD/src ``` -------------------------------- ### Run an example script Source: https://github.com/awv-informatik/smlibpy/blob/main/docs/examples.md Run a script from the examples directory to open the model in the viewer and write a STEP file. ```bash python examples/flange.py ``` -------------------------------- ### Install smlibpy MCP server with pip Source: https://github.com/awv-informatik/smlibpy/blob/main/docs/mcp.md Install the package with the mcp extra and start the server over stdio. The server is part of the package behind the mcp extra. ```bash pip install "smlibpy[mcp]" smlibpy-mcp # speaks MCP over stdio; your agent host starts it ``` -------------------------------- ### make_compatible example: Bezier and Spline Source: https://github.com/awv-informatik/smlibpy/blob/main/src/smlibpy/skill/references/curves/make_compatible.md Creates compatible B-spline copies of a Bezier and a Spline, then verifies the resulting control point counts, shared knots, and curve coincidence. The example also shows averaging corresponding control points to get a halfway curve. ```python a = Bezier((0, 0, 0), (1, 3, 0), (4, 3, 1), (6, 0, 0)) b = Spline((0, 0, 5), (2, 1, 5), (3, -1, 5), (4, 2, 5), (6, 0, 5)) ca, cb = make_compatible(a, b) print(len(a.nurbs().points), len(b.nurbs().points)) # 4 7 print(len(ca.nurbs().points), len(cb.nurbs().points)) # 7 7 print(ca.nurbs().knots == cb.nurbs().knots) # True print(max(a.distance_to(ca.point_at(t)) for t in (0.1, 0.5, 0.9)) < 1e-9) # True: the same curve # a curve halfway between the two: average the corresponding control points mid = [(p + q) * 0.5 for p, q in zip(ca.nurbs().points, cb.nurbs().points)] print(mid[0], mid[-1]) # Vector(0, 0, 2.5) Vector(6, 0, 2.5) ``` -------------------------------- ### Bracket example: L-profile with holes Source: https://github.com/awv-informatik/smlibpy/blob/main/docs/examples.md Creates a mounting bracket by extruding an L-profile, filleting concave edges, and subtracting holes. Uses GridLocations, Hole, and CounterSinkHole. ```py from smlibpy import * def model() -> Part: t = 8 # wall thickness profile = Polygon((0, 0), (60, 0), (60, t), (t, t), (t, 50), (0, 50)) bracket = profile.on(Plane.front).extrude(-40) # front plane faces -Y; extrude backwards bracket = bracket.fillet(bracket.edges().concave(), 6) vertical = bracket.edges().parallel_to(Z) bracket = bracket.fillet(vertical.min_by(X) + vertical.max_by(X), 4) # round both ends base = bracket.faces().facing(Z).bottom() # the base flange's top face at z = t upright = bracket.faces().facing(-X).one() bracket -= (GridLocations(24, 20, 1, 2) * Pos(8) * Hole(3.2, t)).on(base) bracket -= (GridLocations(20, 1, 2, 1) * Pos(0, 8) * CounterSinkHole(3.2, 6, t)).on(upright) return bracket.named("bracket").colored("#7c93b5") ``` -------------------------------- ### export_dxf and import_dxf example Source: https://github.com/awv-informatik/smlibpy/blob/main/ai/training/2026-10-13_00-44-16_files-dxf/changes.md Shows exporting a box with a cylindrical hole as a section and side view, exporting a tag with two layers in inches, and importing the tag's cut layer to get its bounding box size. ```python part = Box(40, 30, 20) - Cylinder(8, 30) export_dxf(part.section(Plane.XY), "section.dxf") # 4 LINE, 1 CIRCLE export_dxf(part.section(Plane.XZ), "side.dxf") # x = X, y = Z tag = [RoundedRectangle(40, 12, 2).named("cut"), Text("PART 7", 5).named("engrave")] export_dxf(tag, "tag.dxf", unit="inch") # two layers, inches print(import_dxf("tag.dxf", layers=["cut"]).bbox().size) # Vector(40, 12, 0) ``` -------------------------------- ### KernelWorker.start Source: https://github.com/awv-informatik/smlibpy/blob/main/smlibpy-three/API.md Starts the worker immediately, if it hasn't started yet. Resolves once the worker has loaded its kernel and functions, returning their names. ```APIDOC ## start ### Description Starts the worker now (it starts with the first call otherwise); resolves once it has loaded its kernel and functions, to their names. ### Method start ### Signature `start(): Promise` ### Returns - Promise - Resolves to the names of the loaded functions. ``` -------------------------------- ### Install @classcad/smlibpy-three and three Source: https://github.com/awv-informatik/smlibpy/blob/main/README.md Install the smlibpy-three package and its peer dependency three.js via npm. ```bash npm install @classcad/smlibpy-three three ``` -------------------------------- ### Install smlibpy MCP plugin in Claude Code Source: https://github.com/awv-informatik/smlibpy/blob/main/README.md Add the smlibpy marketplace and install the plugin for Claude Code to enable the MCP server for AI agents. ```bash claude plugin marketplace add awv-informatik/smlibpy claude plugin install smlibpy@smlibpy ``` -------------------------------- ### Measure a part's volume, area, bounding box, and validity Source: https://github.com/awv-informatik/smlibpy/blob/main/docs/getting-started.md Volumes, areas, and centers are integrated over the exact geometry, not a mesh, to seven significant digits. The printed values are examples; actual values depend on the part. ```python print(round(plate.volume, 3)) # 43040.0 print(plate.area) print(plate.bbox().size) # Vector(80, 60, 10) print(plate.is_valid()) # a closed, manifold solid with a positive volume ``` -------------------------------- ### show() example with plate and cover Source: https://github.com/awv-informatik/smlibpy/blob/main/src/smlibpy/skill/references/files/show.md Creates a plate and cover shape, then opens them in an interactive 3D viewer. The example writes an HTML page to 'plate.html' without opening the browser, and prints the returned path. ```python plate = Box(60, 40, 8) - Cylinder(4, 10) cover = Box(60, 40, 2).translate(0, 0, 10).named("cover") page = show(plate, cover, title="plate", path="plate.html", open_browser=False) print(page) # plate.html ``` -------------------------------- ### Create a rounded rectangle sketch Source: https://github.com/awv-informatik/smlibpy/blob/main/ai/training/2026-10-12_21-26-11_sketches-generic/changes.md Constructs a RoundedRectangle sketch with width 80, height 50, and corner radius 8. This is the starting point for the example in the 'Example' section. ```python outline = RoundedRectangle(80, 50, 8) ``` -------------------------------- ### Build smlibpy-three with npm Source: https://github.com/awv-informatik/smlibpy/blob/main/AGENTS.md Installs dependencies, typechecks, runs tests, and builds the package after smlibwasm is built. ```bash npm ci ``` ```bash npm run typecheck ``` ```bash npm test ``` ```bash npm run build ``` -------------------------------- ### Profile example: section, bracket, u_turn, path, pipe, base, square, round_top Source: https://github.com/awv-informatik/smlibpy/blob/main/ai/training/2026-10-13_00-42-19_sketches-profiles/changes.md Demonstrates Profile construction with line_to, fillet, chamfer, arc, mirror, close, wire, and sweep. Includes comments with computed areas and volumes. The base profile is reused for square and round_top, showing that base remains unchanged. ```python section = (Profile((0, 0)) .line_to(12, 0).line_to(y=4).fillet(1.5) .line_to(x=6).line_to(y=20).chamfer(1) .line_to(x=0) .close()) bushing = section.revolve(Axis((0, 0, 0), (0, 1, 0))) # area 143.0171, volume 3565.9232 bracket = (Profile((0, 0)) .line_to(30, 0).line_to(y=6) .line_to(x=10).fillet(4) .line_to(y=30) .arc(10, 90) .mirror(Y) .close()) # 60 x 40, area 1003.9469, 10 edges u_turn = Profile((0, -3)).forward(20).arc(3, 180).forward(20).arc(3, 180).close() # a slot, 20*6 + 9*pi path = Profile((0, 0)).line_to(20, 0).fillet(5).line_to(20, 20).wire() pipe = sweep(Circle(1), path) # volume = pi * path.length = 118.9218 base = Profile((0, 0)).line_to(20, 0).line_to(20, 10) square = base.line_to(0, 10).close() # 200 round_top = base.arc_to(0, 10).close() # 357.0796, base is unchanged ``` -------------------------------- ### ParabolicArc example Source: https://github.com/awv-informatik/smlibpy/blob/main/src/smlibpy/skill/references/curves/ParabolicArc.md Creates parabolic arcs and a reflector. The first arc uses focal length 25, the second uses focal length 10 in the XZ plane. The example prints the start and end points of the first arc. ```python dish = ParabolicArc((0, 0), 25, 0, 40) # y = x^2/100, x 0..40; the focus at (0, 25) reflector = revolve(make_face(dish + Line(dish.end, (0, 16)) + Line((0, 16), (0, 0))), Axis.Y) print(dish.start, dish.end) # (0, 0, 0) (40, 16, 0) side = ParabolicArc((0, 0), 10, -20, 20, Plane.XZ) # in the XZ plane, opening along Z ``` -------------------------------- ### ConicArc example Source: https://github.com/awv-informatik/smlibpy/blob/main/src/smlibpy/skill/references/curves/ConicArc.md Creates a conic arc with the given start, apex, end, and rho. The first example uses rho = sqrt(2) - 1 to produce a quarter circle of radius 10, and point_at(0.5).length returns 10.0. The other two examples use rho 0.3 (flatter than a parabola) and 0.8 (close to the apex). ```python corner = ConicArc((10, 0), (10, 10), (0, 10), math.sqrt(2) - 1) # the quarter circle of radius 10 print(corner.point_at(0.5).length) # 10.0 soft = ConicArc((0, 0), (10, 0), (10, 10), 0.3) # flatter than a parabola full = ConicArc((0, 0), (10, 0), (10, 10), 0.8) # close to the apex ``` -------------------------------- ### twist(angle) with start and end limits Source: https://github.com/awv-informatik/smlibpy/blob/main/docs/deform.md Twists every cross-section about the Z axis by an angle that grows evenly along the axis. The `start` and `end` parameters limit the twist to a portion of the part; sections before `start` remain unchanged and sections beyond `end` are turned as a whole. The example shows that the sides are split where the twist begins and ends, resulting in 14 faces. ```python baluster = Box(16, 16, 200).twist(360, start=-50, end=50) print(len(baluster.faces())) # 14: the sides are split where the twist begins and ends ``` -------------------------------- ### Example bracket: create, export, import, and simplify Source: https://github.com/awv-informatik/smlibpy/blob/main/src/smlibpy/skill/recipes/simplify.md Builds the example bracket, exports it to STEP, imports it back, then removes fillets and holes. Shows the expected face counts, volumes, and validity checks. Use partial=True on imported parts to keep details that cannot be removed. ```python t = 8 bracket = Polygon((0, 0), (60, 0), (60, t), (t, t), (t, 50), (0, 50)).on(Plane.front).extrude(-40) bracket = bracket.fillet(bracket.edges().concave(), 6) vertical = bracket.edges().parallel_to(Z) bracket = bracket.fillet(vertical.min_by(X) + vertical.max_by(X), 4) base, upright = bracket.faces().facing(Z).bottom(), bracket.faces().facing(-X).one() bracket -= (GridLocations(24, 20, 1, 2) * Pos(8) * Hole(3.2, t)).on(base) bracket -= (GridLocations(20, 1, 2, 1) * Pos(0, 8) * CounterSinkHole(3.2, 6, t)).on(upright) export_step(bracket, "bracket.step") part = import_step("bracket.step") print(len(part.faces()), round(part.volume, 3), len(part.faces().fillets())) # 19 31287.064 5 simple = part.remove_fillets(max_radius=5, partial=True) # small rounds; keep what cannot go print(len(simple.faces()), len(simple.faces().fillets(max_radius=5))) # 18 3 holes = part.faces().filter(lambda f: f.geom_type in ("cylinder", "cone") and f not in part.faces().fillets()) plain = part.remove_faces(holes, partial=True) # holes straight from the import print(len(plain.faces()), round(plain.volume, 3)) # 13 32550.726 print(plain.is_valid(), len(plain.solids())) # True 1 ``` -------------------------------- ### HyperbolicArc example: waist and tower Source: https://github.com/awv-informatik/smlibpy/blob/main/src/smlibpy/skill/references/curves/HyperbolicArc.md Creates a hyperbolic arc with center (0,0), x_radius 10, y_radius 20, from y=-30 to y=30. The printed output shows start, midpoint, and end points. The tower example revolves a face made from the arc and three lines around Axis.Y. ```python waist = HyperbolicArc((0, 0), 10, 20, -30, 30) # radius 10 at y = 0, 18.03 at y = +-30 print(waist.start, waist.point_at(0.5), waist.end) # (18.03, -30, 0) (10, 0, 0) (18.03, 30, 0) tower = revolve(make_face(waist + Line(waist.end, (0, 30)) + Line((0, 30), (0, -30)) + Line((0, -30), waist.start)), Axis.Y) ``` -------------------------------- ### smlibwasm browser example: import and model Source: https://github.com/awv-informatik/smlibpy/blob/main/js/demo/index.html Imports the smlibwasm module, creates a plate with fillets and holes, and a ring, then outputs results. Uses performance timing and error handling. ```javascript // smlibwasm in the browser: the package (dist, npm run build) and the WebAssembly module (wasm, // npm run wasm), served from js/. const out = document.getElementById('out') const lines = [] const say = (line) => { lines.push(line); out.textContent = lines.join('\n') } try { const t0 = performance.now() const s = await import('../dist/index.js') say(`kernel loaded in ${(performance.now() - t0).toFixed(0)} ms`) const t1 = performance.now() let plate = s.Box(80, 60, 10) plate = plate.fillet(plate.edges().parallelTo(s.Z), 8) plate = plate.cut(s.GridLocations(60, 40, 2, 2).mul(s.Cylinder(4, 10))) say(`${plate}`) say(`volume ${plate.volume.toFixed(6)} (exact ${(((80 * 60 - (4 - Math.PI) * 64) - 4 * Math.PI * 16) * 10).toFixed(6)})`) say(`${plate.mesh()}`) const ring = s.Circle(10).cut(s.Circle(4)).extrude(5) say(`ring ${ring}, ${ring.faces().length} faces`) say(`modeled in ${(performance.now() - t1).toFixed(0)} ms`) say('ok') } catch (e) { say(`failed: ${e && e.stack ? e.stack : e}`) } ``` -------------------------------- ### Wedge basic ramp example with bbox and volume Source: https://github.com/awv-informatik/smlibpy/blob/main/ai/training/2026-10-12_21-26-09_parts-primitives/changes.md Creates a wedge ramp with half width, prints bounding box and volume, and lists vertex XZ coordinates. ```python # A ramp 20 long (X), 10 wide (Y), 8 high (Z): pass HALF the width ramp = Wedge(20, 5, 8) print(ramp.bbox(), round(ramp.volume, 3)) # x -10..10, y -5..5, z -4..4, volume 800 print(sorted({(round(v.x, 3), round(v.z, 3)) for v in ramp.vertices()})) # top edge at x = -10 ``` -------------------------------- ### outline example: top/bottom views and cylinder front view Source: https://github.com/awv-informatik/smlibpy/blob/main/ai/training/2026-10-12_21-35-12_analysis-queries/changes.md Shows how to get 2D outlines of a body using `outline` with different planes. The first part creates a box with a blind hole and gets top and bottom views, printing edge counts and lengths. The second part gets the front view of a cylinder and prints its edge count and bounding box size. ```python part = Box(30, 30, 10) - Cylinder(5, 6, align=(Align.CENTER, Align.CENTER, Align.MIN)).translate(0, 0, -5) top_view = part.outline(Plane.XY) # seen from +Z: the blind hole underneath is hidden bottom_view = part.outline(Plane.bottom) # seen from -Z: the hole shows print(len(top_view), len(bottom_view)) # 4 5 print(sorted(round(e.length, 4) for e in bottom_view)) # [30.0, 30.0, 30.0, 30.0, 31.4159] front = Cylinder(5, 20).outline(Plane.XZ) # Plane.XZ looks from -Y: a 10 x 20 rectangle print(len(front), front.bbox().size) # 6 Vector(10, 0, 20) ``` -------------------------------- ### init Source: https://github.com/awv-informatik/smlibpy/blob/main/smlibpy-three/API.md Loads the package with its kernel from where `options` say. Call it before anything imports '@classcad/smlibpy-three', and take the package from its promise. ```APIDOC ## init ### Description Loads the package with its kernel from where `options` say. Call it before anything imports '@classcad/smlibpy-three', and take the package from its promise. ### Method init ### Signature ```ts export function init(options?: InitOptions): Promise; ``` ### Parameters #### InitOptions (optional) - **locateFile** (function) - Optional - The URL of a file of the kernel (`smlibwasm.wasm`) from its name and the loader's directory. - **wasmBinary** (ArrayBuffer | ArrayBufferView) - Optional - The kernel's bytes, fetched already. - **wasmModule** (WebAssembly.Module) - Optional - The kernel compiled already (WebAssembly.compile). - **instantiateWasm** (function) - Optional - Emscripten's own hook: instantiates the module with `imports` and hands the instance to `receive`. ### Response Returns a Promise that resolves to the package module (typeof import('./index.ts')). ``` -------------------------------- ### loft example from docs/parts.md (straight) Source: https://github.com/awv-informatik/smlibpy/blob/main/ai/todo/features.md User docs example for loft with Rectangle and RegularPolygon sections. Produces an hourglass shape with mid-section area 6.4 and volume 2284.7 instead of ~6500. Sections are matched by start points, causing twisting and pinching; all results pass is_valid(). ```python loft([Rectangle(20, 20), RegularPolygon(10, 6).translate(0, 0, 20)], ruled=True) ``` -------------------------------- ### export_step example with assembly, inch unit, and Step items Source: https://github.com/awv-informatik/smlibpy/blob/main/src/smlibpy/skill/references/files/export_step.md Shows exporting parts to STEP, including assembly products, inch unit conversion, and StepCurve/StepPoint/StepFrame items. The first export writes 'assembly.step' with products 'bracket' and 'cover'; the second writes 'bracket_inch.step' with coordinates converted to inches; the third writes 'fixture.step' with a tool path, reference point, and mounting system. The example also demonstrates importing the files back and printing names, volumes, bounding box size, and model contents. ```python bracket = (Box(60, 40, 8) - Cylinder(4, 10)).named("bracket").colored("steelblue") cover = Box(60, 40, 2).translate(0, 0, 10).named("cover").colored("#d9925a") export_step([bracket, cover], "assembly.step", assembly=True) # products "bracket", "cover" back = import_step("assembly.step") print([p.name for p in back], round(back[0].volume, 3), round(bracket.volume, 3)) # ['bracket', 'cover'] 18797.876 18797.876 # an inch file: the coordinates are converted to inches export_step(bracket, "bracket_inch.step", unit="inch") print(import_step("bracket_inch.step").bbox().size) # Vector(60, 40, 8) # a part with its tool path, a reference point and its mounting system path = Wire([Line((0, 0, 4), (30, 0, 4)), CenterArc((30, 10), 10, -90, 180)]) export_step([bracket, StepCurve("path", path, color=(1, 0, 0)), StepPoint("CRP", Vector(0, 0, 4)), StepFrame("MCS", Plane((0, 0, 4)))], "fixture.step") model = read_step("fixture.step") print(model) # StepModel(1 bodies, 1 frames, 1 curves, 1 points) print(model.curves[0].name, round(model.curves[0].shape.length, 4)) # path 61.4159 ``` -------------------------------- ### slices example: part and mesh slicing Source: https://github.com/awv-informatik/smlibpy/blob/main/src/smlibpy/skill/references/features/slices.md Cuts a part or mesh into layers of given thickness along an axis. The example shows slicing a box with a cylindrical bore, printing section plane origins and areas, slicing across the X axis, and slicing a mesh to get wire loops. ```python part = Box(40, 30, 20) - Cylinder(6, 40) layers = part.slices(5) print([round(s.plane.origin.z, 1) for s in layers]) # [-7.5, -2.5, 2.5, 7.5] print(round(layers[0].area, 3)) # 1086.903 = 40*30 - pi*6^2 across = part.slices(7, X) # x -16.5 ... 18.5 print([round(s.area, 1) for s in across]) # [600.0, 600.0, 381.8, 441.3, 600.0, 600.0] contours = part.mesh(0.01).slices(5) # the same for a mesh: loops of wires print([len(c) for c in contours]) # [2, 2, 2, 2]: outline and bore ``` -------------------------------- ### Build smlibpy from source Source: https://github.com/awv-informatik/smlibpy/blob/main/README.md Clone the repository recursively and install from source. Requires CMake and a C++17 compiler; build takes about a minute on a laptop. ```bash git clone --recursive https://github.com/awv-informatik/smlibpy cd smlibpy pip install . ``` -------------------------------- ### Extend and Untrim a Face (face.extend, face.untrimmed) Source: https://github.com/awv-informatik/smlibpy/blob/main/docs/surfaces.md Extends a face's surface past its sides by a distance using the default 'natural' continuation, and gets the whole underlying surface of a face without holes or cut borders. The first example extends a top face of a box by 3 units, resulting in a 16x16 plane with area 256.0. The second example gets the untrimmed area of a cylindrical face from a box with a cylinder cutout, which is 1005.31 (2 * pi * 4 * 40). ```python top = Box(10, 10, 10).faces().filter(lambda f: f.normal_at().z > 0.5)[0] print(top.extend(3).area) # 256.0: a plane 16 x 16 wall = (Box(20, 20, 20) - Cylinder(4, 40)).faces().filter(lambda f: f.geom_type == "cylinder")[0] print(round(wall.untrimmed().area, 2)) # 1005.31 = 2 pi 4 40 ``` -------------------------------- ### Profile.start Source: https://github.com/awv-informatik/smlibpy/blob/main/docs/api.md Property that returns the starting point of the drawing. ```APIDOC ## Profile.start ### Description Where the drawing started. ### Signature ```python @property def Profile.start(self) -> Vector ``` ### Returns - **Vector** - The starting point. ``` -------------------------------- ### taper(scale) with start and axis parameters Source: https://github.com/awv-informatik/smlibpy/blob/main/docs/deform.md Scales cross-sections toward an axis from their size at `start` to `scale` times that size at `end`. Lines along the axis stay straight, so a cylinder becomes a cone and a box a frustum. The example shows a box flaring from z = 10 upward and another tapering along the X axis. ```python post = Box(40, 40, 60).taper(1.4, start=10) # flares from z = 10 upward wedge = Box(100, 20, 20).taper(0.25, axis=X) # along X ``` -------------------------------- ### init(options?: InitOptions): Promise Source: https://github.com/awv-informatik/smlibpy/blob/main/docs/javascript.md Initializes the kernel and returns the module's exports. ```APIDOC ## init(options?: InitOptions): Promise ### Description Initializes the kernel and returns the module's exports. ### Method Function ### Signature `init(options?: InitOptions): Promise` ### Parameters - **options** (object) - Optional - Initialization options: - `locateFile` (function) - Optional - Function to locate files. - `wasmBinary` (ArrayBuffer or ArrayBufferView) - Optional - Preloaded WASM binary. - `wasmModule` (WebAssembly.Module) - Optional - Precompiled WASM module. - `instantiateWasm` (function) - Optional - Custom instantiation function. ### Returns - **Promise** - Resolves with the module's exports. ``` -------------------------------- ### Build smlibwasm with npm Source: https://github.com/awv-informatik/smlibpy/blob/main/AGENTS.md Installs dependencies, builds the WASM module (requires Emscripten SDK in `~/emsdk`), typechecks, and builds the package. ```bash npm ci ``` ```bash npm run wasm ``` ```bash npm run typecheck ``` ```bash npm run build ``` -------------------------------- ### Part.taper(scale, start=None, end=None) Source: https://github.com/awv-informatik/smlibpy/blob/main/ai/training/2026-10-13_01-21-12_deform-twist-taper-bend-lattice/changes.md Tapers the part by scaling cross-sections between start and end distances. The result is exact NURBS. ```APIDOC ## [POST] Part.taper ### Description Tapers the part by scaling cross-sections between start and end distances. The result is exact NURBS. ### Method POST ### Endpoint Part.taper(scale, start=None, end=None) ### Parameters #### Path Parameters - **scale** (float) - Required - Scale factor. Must be positive and not 1. - **start** (float) - Optional - Distance along the axis from the origin where the taper begins. Default: part's extent. - **end** (float) - Optional - Distance along the axis from the origin where the taper ends. Default: part's extent. ### Response #### Success Response (200) - **Part** - The tapered part. ### Request Example ```python # Example not provided in source ``` ``` -------------------------------- ### Modeling check and build example Source: https://github.com/awv-informatik/smlibpy/blob/main/ai/training/2026-10-12_21-44-19_features-mirror-split-section-misc/changes.md Shows a recommended modeling order: main body, additions, subtractions, fillets/chamfers, shell, then final holes. The check() helper validates validity, positive volume, single solid, and optional expected volume. The example builds a box, fillets vertical edges, shells the top face, and subtracts a cylinder. ```python def check(tag, part, expected=None): ok = part.is_valid() and part.volume > 0 and len(part.solids()) == 1 if expected is not None: ok = ok and abs(part.volume - expected) <= 1e-6 * expected print(tag, ok, round(part.volume, 3), part.bbox().size.to_tuple()) return ok body = Box(60, 40, 20) check("box", body, 60 * 40 * 20) body = body.fillet(body.edges().parallel_to(Z), 6) check("corners", body, 48000 - 4 * (36 - 9 * math.pi) * 20) body = body.shell(2, body.faces().planar().top()) check("shell", body) body -= Cylinder(4, 10).translate(0, 0, -10) check("hole", body) ``` -------------------------------- ### Helix example Source: https://github.com/awv-informatik/smlibpy/blob/main/ai/training/2026-10-12_21-36-18_curves-freeform/changes.md Creates a right-handed helix, a left-handed helix, a conical helix, and a long helix chained with a Wire. Prints start, end, and point at quarter turn. ```python h = Helix(pitch=5, height=20, radius=10) # (10, 0, 0) -> (10, 0, 20), 4 turns lh = Helix(5, 20, 10, left_handed=True) cone = sweep(Circle(0.8), Helix(5, 20, 10, end_radius=4)) long = sweep(Circle(1), Wire([Helix(4, 12, 8), Helix(4, 12, 8, center=(0, 0, 12))])) print(h.start, h.end, h.point_at(1 / 16)) # quarter turn: (0, 10, 1.25) ``` -------------------------------- ### taper example: cone, grip, post, wedge Source: https://github.com/awv-informatik/smlibpy/blob/main/ai/training/2026-10-13_01-21-12_deform-twist-taper-bend-lattice/changes.md Shows exact taper results: a cylinder becomes a cone, fillets taper with the part, a box flares from a start offset, and an off-axis taper along X. Prints volumes, validity, face count, and bounding box. ```python cone = Cylinder(10, 50).taper(0.5) # exact frustum of a cone print(round(cone.mass_properties(accuracy=1e-10).volume, 3), round(math.pi * 50 / 3 * (100 + 50 + 25), 3)) grip = Cylinder(12, 90) grip = grip.fillet(grip.edges(), 4).taper(0.75) # the rounds taper with it print(grip.is_valid(), len(grip.faces())) post = Box(40, 40, 60).taper(1.4, start=10) # flares from z = 10 up, 1.4 x at the top print(post.bbox()) wedge = Box(100, 20, 20).taper(0.25, axis=X) # along X: a quarter of the size at x = 50 print(round(wedge.mass_properties(accuracy=1e-10).volume, 3)) ``` -------------------------------- ### Build docs with mkdocs Source: https://github.com/awv-informatik/smlibpy/blob/main/AGENTS.md Builds the documentation with strict mode, which fails on warnings. ```bash mkdocs build --strict ``` -------------------------------- ### Mirror a part and print bbox size Source: https://github.com/awv-informatik/smlibpy/blob/main/ai/training/2026-10-13_00-42-19_sketches-profiles/changes.md Example from the mirror feature page: mirror a half part and print the bounding box size. ```python print(pair.bbox().size.to_tuple()) # (40.0, 10.0, 10.0) ``` -------------------------------- ### Create a plate with fillets, holes, and a pocket Source: https://github.com/awv-informatik/smlibpy/blob/main/docs/getting-started.md Build a part from a primitive (Box) and a sketch (Rectangle). Each operation returns a new part; nothing is modified in place. The `-=` operator is shorthand for `= -`. ```python plate = Box(80, 60, 10) # centered on the origin plate = plate.fillet(plate.edges().parallel_to(Z), 8) # round the four vertical edges plate -= GridLocations(60, 40, 2, 2) * Cylinder(4, 10) # subtract four cylinders pocket = Rectangle(30, 20).on(plate.faces().top()) # a sketch on the top face plate -= pocket.extrude(-4) # extruded into the plate ``` -------------------------------- ### Polygon usage examples Source: https://github.com/awv-informatik/smlibpy/blob/main/ai/training/2026-10-13_00-42-19_sketches-profiles/changes.md Examples of creating polygons with and without fillet. The first creates a profile with area 600, the second extrudes it on Plane.XZ, the third centers it, and the fourth uses fillet=2 to round corners. ```python profile = Polygon((0, 0), (30, 0), (30, 10), (10, 25), (0, 25)) # area 600, bbox 0..30 x 0..25 ``` ```python rib = profile.on(Plane.XZ).extrude(4) # stands up in XZ, 4 thick toward -Y ``` ```python centered = Polygon((10, 10), (20, 10), (15, 20), align=Align.CENTER) ``` ```python angle = Polygon((0, 0), (40, 0), (40, 8), (8, 8), (8, 30), (0, 30), fillet=2) # area 492.5664 ``` -------------------------------- ### outline example: cylinder front view Source: https://github.com/awv-informatik/smlibpy/blob/main/src/smlibpy/skill/references/analysis/outline.md Outlines a cylinder from the front (Plane.XZ) to get a 10 x 20 rectangle. The bounding box size is Vector(10, 0, 20). ```python front = Cylinder(5, 20).outline(Plane.XZ) # Plane.XZ looks from -Y: a 10 x 20 rectangle print(len(front), front.bbox().size) # 4 Vector(10, 0, 20) ``` -------------------------------- ### Patterns of locations: multiply a pattern with a shape Source: https://github.com/awv-informatik/smlibpy/blob/main/docs/api.md Multiply a pattern with a shape to get one copy per location. The examples show six circles, six cylinders on a circle, and subtracting holes from a part. ```python holes = GridLocations(20, 20, 3, 2) * Circle(2) # six circles ``` ```python bolts = PolarLocations(30, 6) * Cylinder(3, 10) # six cylinders on a circle ``` ```python part -= (GridLocations(40, 30, 2, 2) * Hole(3, 10)).on(top_face) ``` -------------------------------- ### Create a compression spring with ground ends Source: https://github.com/awv-informatik/smlibpy/blob/main/docs/examples.md Sweeps a circle along a helix to form a coil, then splits it at the top and bottom to create flat ground ends. The resulting part is named 'spring' and colored purple. ```python from smlibpy import * def model() -> Part: coil = sweep(Circle(1.2), Helix(pitch=6, height=48, radius=10)) coil = coil.split(Plane.XY.offset(1.2)).split(Plane.XY.offset(48 - 1.2), keep="below") return coil.named("spring").colored("#9d87c7") ``` -------------------------------- ### Profile.start property Source: https://github.com/awv-informatik/smlibpy/blob/main/docs/api.md Returns the starting position of the drawing. ```python @property def Profile.start(self) -> Vector ``` -------------------------------- ### Vertex example: box corners, equality, edges, faces, fillet Source: https://github.com/awv-informatik/smlibpy/blob/main/src/smlibpy/skill/references/selection/Vertex.md Shows how to select a vertex of a box, compare it by position, get its edges and faces, use it in a Line, and round corners of a rectangle with Sketch.fillet. Outputs are shown in comments. ```python box = Box(10, 10, 10) corner = box.vertices().top().right().back().one() print(corner, corner.x, corner.point) # Vertex(5, 5, 5) 5.0 Vector(5, 5, 5) print(corner == Vertex(5, 5, 5)) # True: equal by position print(len(corner.edges()), len(corner.faces())) # 3 3 print(round(Line(corner, Vertex(0, 0, 0)).length, 6)) # 8.660254 sk = Rectangle(20, 10) rounded = sk.fillet(2, sk.vertices().right()) # round only the two right corners print(round(rounded.area, 4)) # 198.2832 ``` -------------------------------- ### Shell.show(path=..., open_browser=False) Source: https://github.com/awv-informatik/smlibpy/blob/main/ai/training/2026-10-12_21-26-09_surfaces-workflow/changes.md Writes the HTML viewer for the Shell. ```APIDOC ## Shell.show(path=..., open_browser=False) ### Description Writes the HTML viewer for the Shell. ### Method show ### Parameters - **path** (string) - Optional - The file path to write the viewer to. - **open_browser** (boolean) - Optional - Whether to open the browser. Default is False. ### Returns - **None** ``` -------------------------------- ### Unroll a ring with unroll(radius=...) Source: https://github.com/awv-informatik/smlibpy/blob/main/docs/deform.md Lays a part wrapped around an axis out flat. The layer at the given radius keeps its length; material inside gets longer, outside shorter. The axis defaults to Z through the origin; start sets the direction to the line that stays in place. The part must not reach the axis, cover less than a full turn, and not reach the half-plane opposite start. ```python ring = Cylinder(52, 40) - Cylinder(50, 50) - Box(60, 60, 50, align=(Align.MIN, Align.MIN, Align.CENTER)) strip = ring.unroll(radius=51) # the three quarter ring, flat print(len(strip.faces().planar()), round(strip.volume, 6) == round(ring.volume, 6)) # 6 True label = ring.unroll(radius=52, start=(-2, -1, 0)) # the outside keeps its length ``` -------------------------------- ### Repository development commands Source: https://github.com/awv-informatik/smlibpy/blob/main/smlibpy-three/README.md Commands for testing, building, generating API docs, and running the example page in this repository. Requires building the @classcad/smlibwasm dependency first. ```bash npm install npm test # node's test runner, on the TypeScript sources npm run build # dist/ with declarations that name nothing of smlibwasm's npm run api # API.md, the API reference, from the declarations (after a build) npm run example # the example page (Vite) ``` -------------------------------- ### Export a part to STEP, STL, or GLB Source: https://github.com/awv-informatik/smlibpy/blob/main/docs/getting-started.md The file type follows the extension. STEP exports exact B-rep for CAD systems, STL exports a triangle mesh for 3D printing, and GLB is for the web, Blender, and three.js. ```python plate.export("plate.step") # exact B-rep for any CAD system plate.export("plate.stl") # triangle mesh for 3D printing plate.export("plate.glb") # for the web, Blender, three.js ``` -------------------------------- ### Markdown template for API reference docs Source: https://github.com/awv-informatik/smlibpy/blob/main/ai/HOW-TO-TRAIN.md Template for writing a concise, opinionated API reference doc in `src/smlibpy/skill/references//.md`. Includes sections for signature, returns, gotchas, errors, example, and related APIs. Every code example must have run in a script, unchanged. ```markdown # Box One line: what it makes. ## Signature `Box(length, width, height, *, align=(Align.CENTER, Align.CENTER, Align.CENTER))` What each parameter means, where it is not obvious. Units: mm, degrees. ## Returns A `Part`, centered on the origin by default (bbox −l/2..l/2 ...). ## Gotchas - What surprised you, what fails silently, what is easy to get wrong. ## Errors - `ModelingError: ...` when ...; the fix. ## Example ```python ... # ran in scripts/03-realistic.py ``` ## Related `Cylinder`, `Part.fillet`, ... ``` -------------------------------- ### Part.bend(angle, radius, start=None, end=None) Source: https://github.com/awv-informatik/smlibpy/blob/main/ai/training/2026-10-13_01-21-12_deform-twist-taper-bend-lattice/changes.md Bends the part around a bend axis with a given radius, between start and end distances. The result is within tolerance of the exact image. ```APIDOC ## [POST] Part.bend ### Description Bends the part around a bend axis with a given radius, between start and end distances. The result is within tolerance of the exact image. ### Method POST ### Endpoint Part.bend(angle, radius, start=None, end=None) ### Parameters #### Path Parameters - **angle** (float) - Required - Bend angle in degrees. Must be non-zero and finite, and less than 360. - **radius** (float) - Required - Bend radius. Must be positive. - **start** (float) - Optional - Distance along the bend plane's x_dir from its origin where the bend begins. Default: part's extent. - **end** (float) - Optional - Distance along the bend plane's x_dir from its origin where the bend ends. Default: part's extent. ### Response #### Success Response (200) - **Part** - The bent part. ### Request Example ```python # Example not provided in source ``` ``` -------------------------------- ### load Source: https://github.com/awv-informatik/smlibpy/blob/main/ai/training/2026-10-13_00-44-16_files-dxf/changes.md Reads `.smb`, STEP, STL and DXF files, picking the format from the extension. Returns a `Part` for `.smb`, a `Mesh` for STL, and a `Sketch` for DXF. ```APIDOC ## load ### Description Reads `.smb`, STEP, STL and DXF files, picking the format from the extension. ### Method load ### Parameters #### Path Parameters - **path** (string) - Required - The file path to read. ### Response #### Success Response - **Part** - For `.smb` files. - **Mesh** - For STL files. - **Sketch** - For DXF files. ### Errors - `FileNotFoundError` for a missing file. - `ValueError: unknown file type '.glb'; load reads .step, .stp, .stl, .smb and .dxf`. - `KernelError: load failed`: an `.smb` file the native reader cannot read. ``` -------------------------------- ### Profile usage example Source: https://github.com/awv-informatik/smlibpy/blob/main/docs/api.md Shows a typical Profile drawing sequence: line_to, fillet, chamfer, and close. The result is a Sketch that can be extruded or revolved. ```python section = (Profile((0, 0)) .line_to(12, 0).line_to(y=4).fillet(1.5) .line_to(x=6).line_to(y=20).chamfer(1) .line_to(x=0) .close()) # a Sketch: extrude or revolve it ```