Skip to content

Workflow rules (AGENTS.md)

This is the text every agent works from: the MCP server serves it as b123d-print://guide and inside every prompt, and b123d-print init writes it to a workspace as AGENTS.md. It is included here verbatim from the package.


This workspace holds parts for FDM 3D printing, modeled in Python with build123d and checked with b123d-print. These rules apply to any agent (Claude, Gemini, GPT, local models) and to humans. They come from parts that were actually printed; several rules exist because a print failed without them.

Tools

Use the b123d-print MCP server tools if your client has them (new_part, write_part, build_part, render_preview, section, check, check_fit, export, list_faces, list_edges, make_template, trace_outline, recipe, render_sketch). read_guide returns this guide: call it once before the first part in a session if your client has not loaded it (the b123d-print://guide resource). Otherwise use the CLI:

  • b123d-print new <name> [--sketch] — scaffold parts/<name>/<name>.py (--sketch: sketch first, below)
  • b123d-print sketch <name> [<sketch>] — draw and check a 2D sketch from sketches(d)
  • uv run parts/<name>/<name>.py [--variant <key>] [--formats 3mf,png] [--only <pieces>] or b123d-print build <name> [--only <pieces>] — export to parts/<name>/out/ and run the checks
  • b123d-print check [<name> ...] — checks only; exit code 1 on any failure
  • b123d-print fit [<name>] — fit between the pieces of assembly(d): overlaps, gaps, hole alignment
  • b123d-print trace <image> --dpi N | --grid MM | --reference card — a scan or grid photo to an outline in mm
  • b123d-print recipes [<name>] — tested snippets for common features (teardrop, nut trap, snap arm, ...)
  • b123d-print config — show the print settings in effect (hole compensation, clearance, limits)
  • b123d-print to-step <file.stl> — convert a mesh to STEP and report what the conversion did
  • b123d-print faces <name> / b123d-print template <name> --slice XY:3 | --face ID | --crop x,y,z:sx,sy,sz — list flat faces; make a fit-test template (see below)
  • b123d-print diagnose <name>, b123d-print params <name>, b123d-print set <name> FIELD=VALUE, b123d-print measure <name> --distance A,B | --wall x,y,z | --faces ID,ID | --hole ID — as below

After a failed build, read its DIAGNOSIS (cause, where, fixes with numbers) before changing the script; diagnose_failure looks deeper. Change a dimension with set_params (params lists them), not a rewrite of the script. Check fits and walls with measure (gap or interference, wall at a point, two faces, a hole), not by eye from a render. Pick fillet and chamfer edges with list_edges (CLI b123d-print edges: ids, convex or concave, the faces each joins), then highlight=<ids> for a picture and a verified selector to paste into the script; never put edge ids in the script, they change with the model.

The part script

  1. One script per part at parts/<name>/<name>.py. Units are mm.
  2. Every dimension is a named UPPER_CASE field of a frozen Dims dataclass, with a comment saying where it came from (measured, typed by the user, standard, estimate). No magic numbers in the geometry code. Derived values are @propertys.
  3. Variants (a bigger one, a tilted one) live in the same script, never in a copied folder: VARIANTS = {"": {}, "140": dict(PLATE_W=140.0)} holds only the overrides. Output files get the variant suffix; --variant <key> builds one, the default builds all.
  4. build(d) returns the printable part (or {"name": part} for several), in print orientation, bottom face on Z=0. For several pieces, make the values zero-argument functions (lazy pieces): {"end_rear": lambda: end_rear(d), "key": lambda: key(d)}. Each is built only when that piece is needed, so parts= (MCP) or --only (CLI) builds just the pieces named. Plain shapes work too, but then every call builds them all.
  5. If the part mates with something, assembly(d) returns the parts in assembled position plus simple stand-ins for the things they mate with (board, sensor, screw). Place mating pieces by face contact and hole axes with place_on(piece, face_a, target, face_b, offset=0) and align_axis(piece, axis_a, target, axis_b, clock=...) instead of hand-computed Pos/Rot math. The overlap check uses assembly(d): nothing printed may intersect a stand-in.
  6. views(d) lists cross-sections saved with each export; checks(d) declares wall checks and changes the automatic checks (see below); templates(d) lists fit-test templates exported with every variant (Template.slice("XY", 3), Template.face_of("bottom"), Template.crop(...)).

Sketch first (optional, offer it per part)

For a part that is mostly a 2D shape made solid, offer to draw and confirm the 2D sketch before any 3D: outlines extruded flat (brackets, plates, clips, spacers, gaskets), profiles revolved (knobs, pulleys, spool parts, bushings) and sections swept (hooks, handles). Not for boxy enclosures (box, shell, lid) or organic shapes (use organic). The user may say no; then model as usual.

  1. Confirm the dimensions as always. new_part(name, sketch_first=True) (CLI new --sketch) scaffolds a script whose optional sketches(d) hook returns named 2D shapes, lazy like pieces: {"outline": lambda: outline(d)}.
  2. Draw the outline from points, not from unions of boxes and circles: rounded_outline(points, radii) (one radius per corner, 0 = sharp; it refuses radii that do not fit) and slot(a, b, width) from b123d_print.recipes, holes cut with Circle((d + HOLE_COMP) / 2). A profile to revolve is drawn on Plane.XZ. A traced outline (trace_outline) can be the points.
  3. render_sketch(name, sketch=...) (CLI b123d-print sketch): a PNG on a mm grid with its dimensions (overall size, holes, slots, inside corner radii, centres from the lower-left corner) and the sketch checks: one closed region, narrowest neck vs min_wall, inside corners under R0.5 (BP-R1), holes under 1 mm, the bed. Fix every FAIL, show the picture, and wait for the user's OK on the sketch.
  4. build(d) extrudes, revolves or sweeps the same function's result, then adds the 3D-only features (countersinks, bed_chamfer, which also chamfers inside radii); then the usual flow.

Declared bought hardware (optional)

Use from b123d_print import Hardware and an optional variant-aware hardware(d) hook for user-confirmed bought parts. For example, with confirmed count/specification fields in Dims:

def hardware(d):
    return [Hardware("fastener", "Assembly fastener", d.FASTENER_COUNT,
                     specification=d.FASTENER_SPEC)]

Hardware(id, description, quantity, specification="", location="", note="", source_url="", source="", units="", needs_confirmation=False, model=None) requires a stable unique ID and a positive integer quantity for the whole selected variant's assembly, even with parts= / --only. Leave an unknown specification empty, or mark a partial one needs_confirmation=True; ask the user instead of inferring a thread, screw length/head, insert model or shopping list from holes or meshes. Keep assembly instructions in PRINT_NOTES.

Hardware.from_bd_warehouse("fastener", screw_or_nut_or_washer, quantity=d.FASTENER_COUNT) reuses bd_warehouse's declared class/type/size/length and handedness; add confirmed material, finish or supplier information as needed. Custom hardware can supply model=<shape or lazy zero-argument factory>, with explicit source and source-model units. A factory may call import_model("ref/hardware.stl", scale=<confirmed units>) (STEP/3MF work too): units metadata does not scale geometry, so match it to scale. Keep assets in ref/ for handoff. Put the placed shape in assembly(d) using item.standin(placed_shape, label="instance") (or item.standin() to evaluate its model); use place_on / align_axis for placement. Keep these nonprintable stand-ins out of build(d); they retain the item ID and existing fit checks.

formats="print,hardware" writes the print sheet's Declared hardware table and optional versioned <name>[_<variant>]_hardware.json; both use the same ID-sorted whole-assembly counts, separate from inferred screw-hole advice. all includes both, defaults stay unchanged. Include print,hardware when filtering a download or pull; source and ref/ come home too. Descriptions and source URLs are data, never fetched or executed. A missing hook preserves the legacy sheet.

When the part has hardware, offer hardware_list (CLI b123d-print bom): the shopping list in the result as one table to show the user, identical items merged, count= for several assemblies, several parts merged; format="csv" for a spreadsheet. The bom / bom_csv export formats write it as _bom.md / _bom.csv. Settle every check before ordering item with the user; never fill in a specification yourself.

Repeated features: patterns, one boolean

Holes, bosses, ribs, slots and cells that repeat are placed with build123d's location sets, not computed in a for loop with a boolean on every pass (guide):

  • GridLocations(x_spacing, y_spacing, x_count, y_count) (centered), PolarLocations(radius, count, start_angle=0, angular_range=360, rotate=True), HexLocations(apothem, x_count, y_count) (neighbours 2 x apothem apart), Locations(*d.POINTS), and mirror(shape, about=Plane.YZ) for the other side of a symmetric part.
  • One boolean for all the copies: part -= GridLocations(...) * hole (a list of placed copies), part += [rib(p) for p in d.RIBS], or a with GridLocations(...): context in BuildPart / BuildSketch with mode=Mode.SUBTRACT. A boolean per pass costs far more: 400 holes took 0.22 s fused and 10.2 s one at a time. build_part hints at such loops.
  • Recipes: bolt_circle, hole_grid, hex_grille (honeycomb vents, lightening), slot_grille (vents, speaker slots), grip_ridges, ribs. Continuous features (threads, flutes, spirals) are one sweep or loft, not thousands of copies.
  • Webs between copies at least 2-3 lines [W2, W3], holes at least 1-2 mm [H5], rows of horizontal holes as teardrops [H3], hex cells in a standing wall corner-up [O1].

Big and multi-piece projects

A part that takes long to build makes every step slow. The time limit is 240 s per call.

  • Read the timing report. build_part (and b123d-print build) lists each piece's face count and build time, with a hint on a piece over ~1,500 faces or ~10 s. Fix that piece first.
  • Build each distinct piece once, then mirror or copy it. front = mirror(rear(d)) builds the rear piece a second time. Put @functools.cache on the piece function (Dims is frozen, so d can be its key), or build once and place copies.
  • Keep curves to the points they need. Build time grows with the point count: a 96-point polyline offset and extruded several times makes thousands of faces. Halve the points if the part still looks and fits the same, or use a spline where offsets of it stay robust.
  • Work on one piece at a time with parts="end_rear" on build_part, render_preview, section and export (--only end_rear on the CLI). Never invent a variant just to build fewer pieces.
  • Built pieces are cached in out/.cache/ per variant. render_preview, section, check and export reuse them while the script, its folder's .py files, the files it reads in its folder, the Dims and the settings stay the same. fresh=True rebuilds. A build that reads a file elsewhere in the workspace, or a remix that loads a model, is not cached. check also reuses each unchanged piece's findings, and export skips files and templates already up to date.
  • Consider one part script per piece when pieces share little but their dimensions, so each builds, checks and exports on its own.

The IDs in brackets ([H3]) point to the sourced rules in BEST_PRACTICES, where each one has its sources and range of values. Provisional marks a rule with only one source so far: follow it as a starting point, say so in the report, and never turn it into a default or a check.

Fits and clearances (all per side; say per side or total in every report) [F4]

  • Fit values come from the user's settings, measured with the fit_coupon example; read them with s = load_settings(__file__): s.press_fit (pressed together, ~0.05), s.clearance (sliding, the default fit, 0.2), s.free_fit (turns or moves freely, 0.3), s.pip_clearance (parts printed in place, 0.3). Use a named field (CLEARANCE, FREE_FIT, ...) and the user's own value if they give one. [F1, F2, F3, N6, J3, W7]
  • Don't design a fit that needs better than ±0.2 mm without a coupon; over ~100 mm in ABS, ASA or nylon, mating features far apart drift with shrinkage: place them relative to each other. [F5]

Holes

  • Holes are modeled true to size; the slicer corrects them (its X-Y hole compensation, set from the hole_coupon example). Keep hole fields at the target printed size; a fit adds the clearance (a hole for a 4 mm dowel, sliding: 4 + 2 × clearance). Still cut every hole with HOLE_COMP: float = hole_comp(__file__) added (HOLE_COMP_H: float = hole_comp(__file__, horizontal=True) for holes lying on their side): both are 0 unless the user opted in to build the correction into the files (then they are for that printer only, with the slicer's at 0). Never hard-code a value from somewhere else. Report holes with their cut size. [H1, H2, H4]
  • Horizontal holes get a teardrop (45° pointed roof) or a flat bridged roof, or turn the part so the hole is vertical; the holes check warns on round ones. [H3]
  • Holes that must be precise (bearings, shafts): model them slightly small and ream to size; say so in the report. [H6]

Overhangs, bridges and supports

  • Keep downward faces within the overhang limit (45° from vertical unless the user's max_overhang says more). [O1]
  • A flat ceiling must rest on walls on two opposite sides (a bridge, no longer than max_bridge, 10 mm by default) or get supports; a ceiling hanging off one wall is an overhang. The overhang check reports both. [O3, O4]
  • To avoid supports, in this order: turn the part, chamfer the overhang, split the part, use teardrop or pointed roofs; then supports. Say in the report what needs supports; supported surfaces come out rough. Gaps that support must be cleared out of: at least 5 mm. [S1, S2]
  • For test coupons or deliberate overhangs, declare PRINT intent with a why: PRINT = {"supports": "none", "why": "..."} (also walls, infill, infill_pattern, brim, orientation: "locked"). The print sheet keeps the facts and labels the advice "set by the part"; check reports the overhangs as accepted, and a FAIL stays a FAIL.
  • Provisional (one source, Hackaday): a hole in a ceiling (a counterbore or nut trap opening downward) can print over a one-layer "sacrificial bridge" that is drilled out afterwards. [O5]

Strength and orientation

  • Layers are the weak direction: across them a part has roughly half its strength (much less in ABS/ASA). Orient or split parts so the main tension or bending runs in XY (along the layers): snap arms lying flat, hooks and brackets not standing on their tips. State the load direction and the orientation in the report. [S4, S5, N1]
  • Before exporting, run suggest_orientation (CLI b123d-print orient) if the part isn't obviously flat-bottomed; pass load= for a part that carries load, and apply the Rot(...) it gives in build(d). A tall part on a small footprint warns in check (tip-over): lay it down, or tell the user to use a brim or mouse ears. [B6]
  • Strength comes from walls (perimeters), not infill: size walls and ribs for the load, keep at least ~1.2 mm (three lines) where strength matters, and make walls whole multiples of the line width. Say in the report which features need more slicer perimeters (screw bosses: 3-4 or more). [W3, W4, T8]
  • Fillet internal corners of loaded features (snap-arm roots, pin bases, brackets), at least 0.5 mm and more where there is room. Outside corners print rounded at nozzle scale anyway; never design knife edges. [R1, R3]
  • Ribs and gussets as thick as the wall (no reason to thin them in FDM; at least ~1.5 mm); use them to stiffen large flat walls and against warping. [R4, R5]
  • Provisional (one source, Stratasys Direct): on a bent wall, outer radius = inner radius + wall thickness keeps the wall even. [R2]

Bed, first layer and warping

  • Edges on the bed get a chamfer, not a fillet (a fillet there is an overhang and flares), unless the user says otherwise; the bed edge check warns. Break other sharp edges (~0.5–1 mm). Keep the CAD at nominal size: elephant's foot is the slicer's job. [O2, B1]
  • Provisional (one source, a Bambu forum post): ~0.4–0.6 mm is a typical bed-edge chamfer. [B2]
  • ABS, ASA, PC and nylon warp: for parts over ~100 mm in them, round the footprint corners, break up large flat solid areas, add ribs, and tell the user to use an enclosure and a brim. PLA, PETG and TPU rarely warp. [B3, B4]
  • Shrinkage is compensated per filament in the slicer; keep the CAD nominal. [M1]

Shapes from profiles: hollow, loft, sweep, revolve (recipes)

  • Hollow a body with hollow(part, wall, open="top") (build123d offset(-wall, openings=)), never by subtracting a smaller copy: the wall stays even round fillets and curves. Hollow the plain body first, then add bosses, ribs and holes; outside corner radius ≥ 2 × wall keeps the inside corners round. Enclosures: the rounded_enclosure example. [W3, W4]
  • A part whose section changes along its length (duct and hose adapters, round to square, funnels): transition_loft(a, b, length, wall=, collar_a=, collar_b=); the sides within the overhang limit inside and out, about 1 mm of change in radius per 1 mm of length (the hose_adapter example). [O1]
  • A constant section along a path (hooks, handles, rails, cable channels): swept_section(path, section) with a FilletPolyline, arc or Spline path drawn in XY, so the part lies flat and its load runs along the layers. A changing section: tapered_sweep. [S4, S5]
  • A round part (knob, pulley, wheel, spool end, bushing): draw the half outline as (r, z) points and revolved_profile(points, radius=...); corner radii in the profile, bed corners sharp and chamfered. [O1, B1]

Snap fits and living hinges

  • Use a recipe (recipe tool, b123d_print.recipes) before improvising a snap arm, hinge, nut trap, teardrop hole, lid lip, text, bed chamfer, hollow, loft, sweep or revolve: they are tested and cite their numbers.
  • Snap arms: lie flat (bend in XY), root fillet ≥ 0.5 × arm thickness, taper the arm toward the tip. [N1, N2, N3]
  • Provisional (one source, Fictiv): size the arm with the cantilever strain formula and an allowable strain of PLA 4–8 %, ABS 7 %, nylon 4–15 % (halve it for arms along Z); say it is an estimate. [N4]
  • Provisional (one source, Sovol): arm length/thickness ~8–10 for PLA, ~5–8 for PETG. [N5]
  • Living hinges: 0.4–0.6 mm thick (at least two layers), in nylon, TPU or PP, not PLA or ABS; build the hinge width along Z so strands run across the hinge. A hinge is thinner than min_wall: list it in ThinFeature(..., ignore=[box]). [N7, N8, N9]
  • Provisional (one source, Hubs): working a nylon hinge in boiling water and letting it cool closed makes it last longer. [N10]

Threads, screws and inserts

  • Model threads only at M5–M6 and up; smaller: heat-set inserts, captive nuts or screws into a pilot hole. Use inserts or nuts for parts opened more than a few times. [T1, T5]
  • Heat-set inserts: the insert maker's hole size (CNC Kitchen M3: 4.0 mm) plus HOLE_COMP, blind hole depth = insert length + 1 mm, wall around it at least the maker's minimum (M3: 1.6 mm; add a Wall check); install at print temperature + 10–20 °C. [T2, T3, T4]
  • Self-tapping or thread-forming screws: pilot holes vary by material and orientation (M3 ≈ 2.6–2.9 mm); print a test pair for anything that matters. [T6]
  • Captive hex nut pockets: across-flats + 0.2 mm total. [T7]

Threads, fasteners and gears: the libraries (guide)

  • Use the libraries instead of drawing standard parts: bd_warehouse.thread (IsoThread, PlasticBottleThread for jars and bottles), bd_warehouse.fastener (screw, nut and HeatSetNut sizes), bd_warehouse.open_builds (2020 V-slot rail and T-nut as stand-ins), py_gearworks (spur, helical, herringbone, bevel gears and racks; mesh_to places a pair).
  • Modeled threads: M6 and up, coarse pitch or bottle threads, axis on Z. Pass the user's clearance as manufacturing_compensation (radial, per side), and fade or chamfer the ends. Below M6, use an insert, a nut or a pilot hole. [T1]
  • Holes from bd_warehouse are compensated once. ClearanceHole and TapHole take no compensation, so read their sizes (screw.clearance_hole_diameters["Normal"]) and cut them with + HOLE_COMP. InsertHole cuts the table's drill size, not the maker's hole (CNC Kitchen M4: 5.79 vs 5.6), so cut the maker's size yourself. [H1, T2]
  • Gears: module ≥ 1 (1.5–2 better), backlash on each gear (0.1–0.2 mm per gear), profile shift (17 - z) / 17 below 17 teeth, printed flat, bores chamfered on top only. Put the meshed pair in assembly(d) with a Gap check between them.
  • V-slot: a V key with 45° sides in the slot's groove, shallow enough to clear the T-nut's neck, with the rail and T-nuts as stand-ins in assembly(d).

Text, splitting and gluing

  • Text: on top (XY) faces, ≥ 0.5 mm deep or high (a multiple of the layer height), strokes ≥ ~1 mm, characters ≥ ~5 mm, bold sans-serif. [X1, X3]
  • Text on a curved face (jar, knob, dome): the text_on_surface recipe, method="wrap" on one face (keeps the size), "project" across face edges (stretches on slopes); along an arc: text_on_path. Same minimums, measured on the surface; sunk text forgives thin strokes more than raised. The text is its own solid: a second colour is part & text (sunk) or text - part (raised). A face that does not mesh fails check (a hole in the STL).
  • Text or a logo in a second colour (AMS / MMU): the inlay recipe, or bodies(base=..., inlay=(shape, "white")) with each pocket cut by its own insert. The 3MF is one object with a named, coloured part per body; checks run on the union plus a bodies overlap check. Inlay ≥ 2 layers deep.
  • Split a part when it exceeds the build volume, would need a lot of support, or when pieces can each print in their strongest orientation. Join with a dovetail and dowels or alignment pins (clearance from the fit settings); a glued joint still needs a mechanical key. Glue: CA bonds every common filament; acetone welds ABS/ASA; PETG takes only CA or epoxy. [J1, J2, J4, J5]

Splitting a part

When a part does not fit the bed in any orientation (the fit check fails, or it is bigger than the user's bed), or would print much better in pieces: [J1] (guide)

  1. Propose the cuts and the joint, with reasons, and wait for confirmation: where the load is low, along a design line where the seam hides, so each piece lies on a big flat face without supports and with its load along the layers [J6]. Name the joint: a bowtie key plus square pins for long seams, a dovetail to slide together, inserts and screws to take apart, a lap for glue area [J2].
  2. Use b123d_print.joints, never hand-made joints: split(part, plane, [Bowtie(...), Dowel(...), ...], clearance=d.CLEARANCE) returns the pieces (.a, .b), the loose keys and pins laid flat (.loose) and placed (.placed, for assembly(d)). Joint sizes are named Dims fields. Add Gap checks on a key or pin and Wall checks around the joint features.
  3. Offer a fit-test template of the joint first (Template.crop around the cut, each side), printed with a loose key or pin, before the full pieces.
  4. Assembly notes in the report: the order, the adhesive for the gap (thin CA on faces that touch; CA gel with activator or epoxy in a clearance fit) and clamping [J7]; how to fill and sand the seam if it shows [J8].

Remixing an existing model

When the user gives you someone else's model (STL, 3MF or STEP) to change:

  1. Get it onto the server into parts/<part>/ref/: upload_reference says how for this connection (a folder to copy into, b123d-print push, or a signed curl -fT link).
  2. Inspect before anything else: describe_model (size, units, faces, curved share, holes, repairs, metadata) and its render. A size that suggests inches or cm: ask, then import_model(..., scale="inch").
  3. License: record the source URL, author and license in the script's docstring. -ND allows no remixes: stop and tell the user. -NC: no commercial use. BY: the author must be credited when it is shared. If the file does not say, ask.
  4. Propose MODIFY or REDRAW, with reasons, list the intended changes as named dimensions, and wait for confirmation. MODIFY is the default: always for STEP, and for organic or detailed meshes. Offer REDRAW for a simple prismatic mesh whose proportions change.
  5. MODIFY: base = import_model("ref/<file>") in build(d), then cut and add features with named Dims. Keep the original where the file puts it; if you turn or move it, define original(d) returning it placed the same way. Mesh curves stay faceted: to change a round hole, cut a real cylinder at its center (from describe_model), with HOLE_COMP.
  6. REDRAW: model it from Dims, define original(d) returning the import placed like the redraw, and call before_after before changing any proportion; report the score.
  7. Findings "inherited from the original" were already in the original: report them, but do not "fix" them unless the user asks. Fix every new FAIL. Show before_after in the report, and give the attribution line to use when sharing (e.g. "Remix of by <author>, <license>, <URL>").</li> </ol> <h2 id="replicating-a-physical-part">Replicating a physical part<a class="headerlink" href="#replicating-a-physical-part" title="Permanent link">¶</a></h2> <p>When the user has a physical part (often injection-molded) and wants a printable copy, use the <code>replicate_part</code> prompt's phases (<a href="https://kd5ryn.github.io/b123d-print/using/replicate/">guide</a>). <code>parts/<name>/MEASURE.md</code> is the <strong>replication spec</strong> and the source of truth for every measured value: <code>| Feature | Value | Method | Accuracy | Status | Class | Source | Field | Why changed |</code>.</p> <ol> <li><strong>Identify</strong> what it does, what it mates with and how, how it is loaded and how it was made; ask for the mating parts, the material (a recycling mark), heat, sunlight and how often it comes apart.</li> <li><strong>Plan the measurements and wait:</strong> one row per dimension, values empty, with the method, accuracy, Class and the Dims field it becomes. One datum, not chained; three readings of each critical size in the Value cell (<code>4.21, 4.19, 4.22</code>); on a molded wall, say where it was measured (where it mates, or mid-height) [C2]; threads by diameter and pitch; the photos to take [C10]. Never guess a value.</li> <li><strong>Classify and decide, and wait.</strong> Class <code>critical</code> (mating interfaces, hole sizes and spacings, fits, sealing and bearing faces, snap and latch geometry, threads, the envelope where it fits) or <code>free</code> (styling, ribs, coring, walls away from interfaces). Source <code>measured</code>, <code>standard</code>, <code>derived</code>, <code>changed</code> or <code>estimate</code>. Critical sizes are modeled as measured, or with the reason in Why changed. A molded part is already at nominal size: never add or remove molding shrinkage [C12].</li> <li><strong>Molded features</strong>, each change with its reason in Why changed:</li> <li>Draft: remove it; keep a taper only where it does a job (a taper fit, nesting) [C1].</li> <li>Coring and thin even walls: solid or thicker in a print; keep pockets that do a job [C3]. Ribs: keep where they run, as thick as the wall, or drop them where solid replaces them [C4].</li> <li>Sink marks, parting lines, flash, ejector-pin marks, gates, knit lines: never modeled or measured on [C5].</li> <li>A living hinge is redesigned (0.4–0.6 mm nylon, TPU or PP, or a pin hinge) [C6]; a snap arm is recomputed for the print material and printed flat [C7].</li> <li>Bosses: the position and the screw, not the molded proportions; inserts for screws taken out often; threads only M5–M6 and up; declare the screw as hardware [C8].</li> <li>Material: pick by what the molded resin was chosen for (heat, strain, sunlight, sliding); say the copy is weaker across its layers [C9].</li> <li><strong>Model</strong> every row with a value as the <code>Dims</code> field named in its Field column (or an expression of fields); <strong>verify</strong> with the usual checks, then <code>replication_spec</code> until it has no warnings, <code>measure</code> on the critical features, and a fit-test template of each critical interface. With a scan of the part, <code>original(d)</code> and <code>before_after</code> as in a remix.</li> <li>Provisional (one source, Hackaday): round a reading to the value the designer meant (43.97 → 44 mm, inch vs mm, standard sizes) and say so in Why changed [C11].</li> </ol> <h2 id="output-formats">Output formats<a class="headerlink" href="#output-formats" title="Permanent link">¶</a></h2> <p><code>export</code> writes, per printable part: <strong>STEP</strong> (opens in other CAD — Onshape, Fusion, FreeCAD — as a plain solid without feature history), <strong>STL</strong> and <strong>3MF</strong> (slicers; 3MF keeps units), and <strong>PNG</strong> previews plus the section views. The user picks: the <code>formats</code> setting in their config, or <code>formats="3mf,png"</code> on one export. If the user has not said what they need and the setting is the default, ask once (e.g. "3MF for Bambu/Orca/Prusa, STEP to edit in other CAD?"). The parametric source is always the <code>.py</code> script and its <code>Dims</code>. A multi-body part (<code>bodies(...)</code>) exports one 3MF object with a named, coloured part per body (tell the user to give each part its filament in the slicer), a union STL plus one per body. <code>export</code> sorts <code>parts/<name>/out/</code> by purpose: <code>print/</code> (3MF, STL and the print sheet: what the user opens in the slicer; fit-test templates in <code>print/templates/</code>), <code>cad/</code> (STEP, GLB), <code>images/</code> (previews, sections, before/after, compare) and <code>docs/</code> (BOM, hardware JSON, the 3D view HTML), plus a short <code>out/README.md</code> index. Point the user at <code>out/print/</code> for the slicer. Only the script, <code>ref/</code> and <code>b123d-print.toml</code> need keeping: one export makes <code>out/</code> again. The <strong>print sheet</strong> (<code>formats="print"</code>, off by default) writes <code>out/print/<name>_print.md</code> for the slicer: sizes, filament and time estimates, supports, tip-over, walls and infill, fits and hole compensation. Offer it when the user prints the part themselves; put assembly order, glue and inserts in a <code>PRINT_NOTES</code> field so the sheet carries them. After an export, <strong>offer the 3D view</strong> so the user can turn the part in a browser before printing: the view link <code>export</code> returns over HTTP (no token, it expires), or locally the <code>out/docs/<name>_view.html</code> it names (opens offline); <code>view="assembly"</code> shows the assembly.</p> <h2 id="remote-server-bring-the-part-home-required-last-step">Remote server: bring the part home (required last step)<a class="headerlink" href="#remote-server-bring-the-part-home-required-last-step" title="Permanent link">¶</a></h2> <p>Locally (stdio) everything is already in the project folder:</p> <pre><code>parts/<name>/<name>.py the script (the parametric source) parts/<name>/out/print/... 3MF, STL, print sheet: what goes to the slicer parts/<name>/out/cad/... STEP, GLB parts/<name>/out/images/... renders, section views parts/<name>/out/docs/... BOM, hardware JSON, 3D view HTML parts/<name>/ref/... reference models (remixes) </code></pre> <p>Over <strong>HTTP or SSH</strong> that same layout lives on the server, and the server is a workbench, not storage: its copy is a <strong>temporary working copy, deleted after some days unused</strong> (the results say how many). Use <strong>only the MCP tools and the links they return</strong>: the server gives <strong>no shell, ssh or scp access</strong>, so never try them.</p> <p><strong>A part is not done until its files are on the user's machine: after export, call download_part (embed=True if your shell has no network) and unzip into the project folder, unless the user says to leave them on the server.</strong> A remote <code>export</code> or <code>make_template</code> result ends with this as its <strong>NEXT STEP</strong>. Before reporting, always:</p> <ol> <li><code>download_part("<name>")</code>. Over HTTP it returns one link (no token, it expires): run <code>curl -fLo <name>.zip '<link>'</code> and unzip it <strong>in the project folder</strong> (<code>unzip -o <name>.zip</code>; Windows: <code>tar -xf <name>.zip</code>); it creates <code>parts/<name>/...</code> as above. Over SSH it returns the <code>b123d-print pull <name> --from ...</code> command: run it in the project folder. <strong>If your shell has no network or is sandboxed</strong> (Antigravity/agy, web and mobile clients), call <code>download_part("<name>", embed=True)</code>: the zip (up to 8 MB) comes inside the result, and your client saves it to a file; run <code>unzip -o <saved zip> -d <project folder></code> (one command, no <code>&&</code> or <code>|</code>).</li> <li>Check the files exist on the user's machine (e.g. list <code>parts/<name>/out/print/</code>).</li> <li>Then report, saying where the files are.</li> </ol> <p>If the client cannot run commands, give the user the link (or the command) and say the part is not on their machine yet. <code>variant=</code> and <code>formats=</code> narrow the <code>out/</code> files; per-file links from <code>export</code> and the <code>b123d-print://files/</code> resources still work for single files.</p> <h2 id="versions-and-resuming-a-project">Versions and resuming a project<a class="headerlink" href="#versions-and-resuming-a-project" title="Permanent link">¶</a></h2> <p>The project folder can keep a <strong>version history</strong> (git on the user's machine, made simple): <code>save_version</code>, <code>list_versions</code>, <code>restore_version</code> (CLI <code>b123d-print save</code>, <code>versions</code>, <code>restore</code>). A save takes each part's script, <code>ref/</code>, <code>MEASURE.md</code> and the <code>.py</code> files beside the script, plus <code>b123d-print.toml</code>; never <code>out/</code>.</p> <ul> <li><strong>Offer, never decide:</strong> after a change that built and passed its checks, ask "Save this version? (shelf_bracket: arm 115 → 130 mm)" and call <code>save_version</code> only on a yes. Before a restore, ask too. Nothing is saved automatically.</li> <li><strong>No history yet</strong> (the tools say so): offer once to start one; on a yes, <code>save_version(..., start=True)</code> (CLI <code>b123d-print init --git</code>). It writes a <code>.gitignore</code> that keeps out <code>out/</code>, downloaded zips, tokens and client configs.</li> <li><code>restore_version(part, <number from list_versions>)</code> saves the old files as a <strong>new</strong> version: nothing is lost, and it is refused while the part has unsaved changes (offer to save first). Then <code>build_part</code> and <code>check</code>.</li> <li><strong>Shared server (HTTP/SSH):</strong> the history stays on the user's machine, never on the server; the tools return the commands for the user's project folder. Bring the part home first.</li> <li><strong>Resume a project:</strong> when a part the user has at home is missing on the server (unused workspaces are removed after some days), put it back from their copy: <code>new_part(name)</code>, <code>write_part(name, <their parts/<name>/<name>.py, whole>)</code>, then <code>upload_reference</code> for each file in its <code>ref/</code> (over SSH the <code>b123d-print push</code> command it gives); settings they had in <code>b123d-print.toml</code> go back with <code>save_setup</code>. Never re-create a script from memory.</li> </ul> <h2 id="printer-profile-optional">Printer profile (optional)<a class="headerlink" href="#printer-profile-optional" title="Permanent link">¶</a></h2> <p>By default b123d-print is in generic mode. When <code>list_parts</code> shows no printer (generic mode), offer the first-run setup once before the first part (the <code>setup_workspace</code> prompt; CLI <code>b123d-print setup</code>): printer, material, formats, style, then the calibration coupons. If the user has set a printer (<code>list_parts</code> shows it, or <code>b123d-print printer show</code>), use it: keep the part inside the build volume in print orientation (the <code>fit</code> check fails otherwise — split the part or turn it), make walls whole multiples of the line width, and read the material notes (e.g. PLA is not for outdoor or hot places). Change the printer only when the user asks.</p> <h2 id="photos-and-measurements">Photos and measurements<a class="headerlink" href="#photos-and-measurements" title="Permanent link">¶</a></h2> <ul> <li><strong>Before modeling: list every dimension you read from the photos</strong> and which feature it belongs to, list features you can see that have no dimension, and <strong>wait for the user to confirm</strong>. Do not start modeling on guesses.</li> <li><strong>Photos show intent; typed measurements are truth.</strong> If a photo reading conflicts with a typed number, flag the conflict and use the typed number unless told otherwise.</li> <li><strong>Missing or ambiguous dimension → ask. Don't guess.</strong> If you must assume something to make progress, name it as an estimate in its comment and in your report.</li> </ul> <p><strong>Getting measurements</strong> (the user's guide: <a href="https://kd5ryn.github.io/b123d-print/using/measuring/">Measuring for the AI</a>)</p> <ul> <li><strong>Ask for what decides the model:</strong> the units (confirm every converted inch value in mm), the <strong>datum</strong> every value is measured from, the critical dimensions (what must fit what, and how: press, sliding, free) and the <strong>accuracy</strong> of each value. Measuring from one datum beats chaining; ~0.1 mm is plenty for FDM.</li> <li><strong>Suggest the method for the part:</strong> calipers for small precise parts; a flatbed scan (known DPI) or a square-on photo on a grid mat for flat outlines; a profile gauge, radius gauge, bent wire or tracing for curves; a <strong>table of offsets</strong> (stations at a fixed spacing along a datum line, one height or width per station, level or along the surface stated) for large or curved parts, plus a test section.</li> <li><strong>Trace a scan instead of measuring a flat outline point by point:</strong> <code>upload_reference</code> the image, <code>trace_outline</code> it (scale from the scan's DPI, a grid, a card or two points), show the overlay and confirm one known dimension; photo traces stay estimates.</li> <li><strong>Photos:</strong> ask for a scale reference (ruler, grid, card) in the same plane as the feature, shot square on from a distance; size readings from photos stay estimates.</li> <li><strong>Record</strong> each confirmed value as a named <code>Dims</code> field whose comment gives its source, method and accuracy, and mark estimates as estimates. If the user keeps a <code>MEASURE.md</code> next to the script, treat it as the source of truth and keep the script in step with it.</li> </ul> <h2 id="verify-before-reporting">Verify before reporting<a class="headerlink" href="#verify-before-reporting" title="Permanent link">¶</a></h2> <p>Do all of this every time you change geometry, before telling the user the part is done:</p> <ol> <li><strong>Build it</strong> and confirm every part is a valid solid with the volume and size you expect.</li> <li><strong>Look at the preview render.</strong> Compare it against the user's description and photos.</li> <li><strong>Look at cross-sections</strong> through every pocket, rib, boss, hole and mating feature. Sections show what the 3D render hides.</li> <li><strong>Run the checks</strong> and fix every failure; mention every warning you leave. Every part gets the overhang (with bridges), thin-feature, holes, bed-edge and gap checks automatically. For several pieces with an <code>assembly(d)</code>, also run the fit check (<code>check_fit</code>, CLI <code>b123d-print fit</code>): overlaps, gaps under the clearance and screw holes that do not line up between pieces. It is not part of <code>check</code> unless the script lists <code>Mates()</code> in <code>checks(d)</code>; do that for parts that are always checked as an assembly. <strong>Moving parts</strong> (hinges, flip lids, latches, sliders): declare the motion in <code>checks(d)</code>, <code>Motion(label, axis_point, axis_dir, start_deg, end_deg, against=..., min_clearance=...)</code> or <code>Slide(label, direction, distance, ...)</code> on <code>assembly(d)</code> labels; closed and open both clear does not mean clear in between. Report the smallest clearance and its angle.</li> <li><strong>Wall check around deep cuts:</strong> wherever a cut goes deeper than the wall it starts in (a counterbore into a boss, a pocket next to a rib, a dimple in a thin side), add a <code>Wall</code> check that slices just past the wall and measures the material left around the cut. <code>is_valid</code> and hole-diameter checks do not catch a 0.05 mm skin — a real print broke there. <strong>Read what each Wall and Probe says it measured</strong> (section area, how far <code>near</code> is from material, the measured region; the probe box against the part's bounding box). A check that says OK while measuring the wrong place is worse than none.</li> <li><strong>Pin Wall and Probe to the part as it is used:</strong> if the part has an <code>assembly(d)</code>, declare them with <code>frame="assembly"</code> and the assembly label (<code>Wall("lid", "XY", z, near=..., frame= "assembly")</code>), in assembled coordinates. Then turning the part over for printing, or changing its print orientation later, cannot move the check onto a different feature. Use the default <code>frame="print"</code> only for parts without an assembly, or for properties of the print itself (a wall measured in the orientation it prints in). After changing a part's print orientation, re-check every <code>frame="print"</code> coordinate.</li> <li><strong>Report:</strong> overall size (X × Y × Z), key feature dimensions, validity, the clearances and hole compensation applied, check results, print orientation and any supports needed. On a remote server, bring the part home first (<code>download_part</code>, see <a href="#remote-server-bring-the-part-home-required-last-step">Remote server</a>) and say where it is.</li> </ol> <h2 id="fit-test-templates-before-the-full-print">Fit-test templates (before the full print)<a class="headerlink" href="#fit-test-templates-before-the-full-print" title="Permanent link">¶</a></h2> <p>A template is a quick thin print (1.2 mm by default) cut from the real part, so its holes and clearances are exactly the part's: it checks size, hole pattern and mating fits in minutes, before hours of printing the whole part.</p> <ul> <li><strong>Offer one</strong> when the part mates with something (a board on standoffs, a lid on a box, a bracket on screws in a wall) or has a hole pattern, and the full print is long or the fit uncertain. Say what it checks (outline, hole positions and spacing, a fit) and what it does not (heights and anything outside it).</li> <li><strong>Kinds:</strong> <code>slice</code> (plane <code>XY</code>/<code>XZ</code>/<code>YZ</code> at a Z/Y/X: the part between two planes, e.g. the top of the standoffs), <code>face</code> (one flat face with its holes as a plate: a mounting face), <code>crop</code> (the part inside a box: a corner, a clip, a boss). Separate pieces (or a crop with little bed contact) get a thin base plate that keeps them where they are.</li> <li><strong>Confirm the face or region with the user first:</strong> <code>list_faces(name, highlight=<id or side>)</code> shows the face in red; <code>make_template</code> returns the <code>_where.png</code> picture, the part with the template's source in red. Ids come from <code>list_faces</code>; a side (<code>bottom</code>, <code>top</code>, ...) is the largest face facing that way.</li> <li>Templates are laid flat (template face down) and checked like a part; read the notes: a template printed on its side or turned over checks hole positions and spacing, but hole sizes only where it prints the way the part does. The label is engraved where there is room, never through a feature.</li> <li>Standard fit tests go in <code>templates(d)</code> so <code>export</code> writes them for every variant.</li> <li><strong>Report:</strong> the template's size, what it checks, how to use it (lay it on the board, try the screws), its findings, and where the files are.</li> </ul> <h2 id="design-review-after-the-print-checks-pass">Design review (after the print checks pass)<a class="headerlink" href="#design-review-after-the-print-checks-pass" title="Permanent link">¶</a></h2> <p>The rules and their sources are in <a href="https://kd5ryn.github.io/b123d-print/DESIGN_GUIDE/">DESIGN_GUIDE</a>.</p> <ul> <li>Every part has a <strong>style</strong>: <code>STYLE</code> in <code>Dims</code>, else the workspace <code>style</code> setting, else <code>functional</code>. The styles are <code>functional</code>, <code>modern</code> (minimal), <code>least_cost</code>, <code>rugged</code> (outdoor), <code>soft</code> (handheld), <code>structural</code> (load-bearing: brackets, mounts, clamps, hooks), <code>organic</code> (natural: fruit, plants, animals, figurines, shells, sculpture), <code>decorative</code> (vases, planters, lamp shades, ornaments) and <code>toy</code> (kid-safe: small parts, breakable features, finger traps; it flags likely problems and certifies nothing [DS-K7]). For a new part, if the user has said nothing about looks, ask once; for a part that carries load, suggest <code>structural</code>; for a toy or a child's thing, <code>toy</code>. <strong>For a natural object use <code>organic</code> and start from a recipe</strong> (<code>spine_loft</code>, <code>tapered_sweep</code>, <code>organic_blend</code>, <code>flat_base</code>; the <code>banana</code> example), not from boxes, cylinders and spheres: sections along curves, blended joins, a flat base [DS-O1..O5]. For a vase, planter or lamp shade use <code>decorative</code>: a vase-mode part is modeled as a solid (the slicer makes the one-line wall, no top) with every layer one closed contour, and says so with <code>PRINT = {"vase": True, "why": ...}</code> [DS-D1]; start from the <code>vase_shell</code>, <code>twisted_loft</code> or <code>patterned_surface</code> recipe. The industrial look is functional with <code>EDGES = "chamfer"</code> and exposed standard screws.</li> <li>Optional script fields: <code>SHOW = ["+Y", "+Z"]</code> (sides seen in use, in print orientation) limits the surface findings to those sides; <code>UP = "+Y"</code> is the side up in use (water traps); <code>EDGES = "chamfer"</code> or <code>"fillet"</code> is the edge language.</li> <li>When <code>check</code> has no failures, run the design review (the <code>design_review</code> prompt, or <code>design_metrics</code> plus the rubric): the numbers, renders of the sides seen in use, and 3–7 concrete suggestions, each citing its rule ([DS-G1]) and the numbers it would change.</li> <li><strong>The order before export, every part:</strong> <code>check</code> passes → <code>design_metrics(name, style=...)</code> → <code>suggest_orientation(name)</code> → <code>export</code>. The results of <code>build_part</code>, <code>check</code>, <code>design_metrics</code> and <code>export</code> end with a <strong>Before printing</strong> block: make the calls it lists (it starts again after every edit). With the <code>review</code> setting <code>"warn"</code> (default) <code>export</code> says what was skipped, also on the print sheet; with <code>"required"</code> it refuses until the steps are done, or the user gives a reason: <code>export(name, skip_review="<their reason>")</code>. A calibration coupon says <code>"review": "exempt"</code> in its <code>PRINT</code>.</li> <li><strong>Report; do not change the part without the user's OK.</strong> A trial variant to measure a suggestion is fine; leave the script as it was unless the user agrees.</li> <li>Filament is a simple estimate (roughly ±20 %), print time and supports are rough estimates: say so, and use them to compare versions, not as a quote.</li> <li>Never suggest a proportion rule such as the golden ratio [DS-G9].</li> </ul> <h2 id="checks-reference">Checks reference<a class="headerlink" href="#checks-reference" title="Permanent link">¶</a></h2> <div class="highlight"><pre><span></span><code><span class="kn">from</span><span class="w"> </span><span class="nn">b123d_print</span><span class="w"> </span><span class="kn">import</span> <span class="n">Gap</span><span class="p">,</span> <span class="n">Mates</span><span class="p">,</span> <span class="n">Motion</span><span class="p">,</span> <span class="n">Overhang</span><span class="p">,</span> <span class="n">Probe</span><span class="p">,</span> <span class="n">Slide</span><span class="p">,</span> <span class="n">ThinFeature</span><span class="p">,</span> <span class="n">Wall</span> <span class="k">def</span><span class="w"> </span><span class="nf">checks</span><span class="p">(</span><span class="n">d</span><span class="p">):</span> <span class="c1"># Part names: a single Part returned by build() is "part" (the script's own name also works);</span> <span class="c1"># build() returning {"base": ..., "lid": ...} names them.</span> <span class="k">return</span> <span class="p">[</span> <span class="c1"># thinnest material in the section, within `radius` of `near` (the section's 2D coords:</span> <span class="c1"># XY -> (x, y), XZ -> (x, z), YZ -> (y, z)); fails below `min` (default: config min_wall)</span> <span class="n">Wall</span><span class="p">(</span><span class="s2">"base"</span><span class="p">,</span> <span class="s2">"XY"</span><span class="p">,</span> <span class="n">d</span><span class="o">.</span><span class="n">FLOOR_T</span> <span class="o">+</span> <span class="mf">1.0</span><span class="p">,</span> <span class="n">near</span><span class="o">=</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">),</span> <span class="n">radius</span><span class="o">=</span><span class="mi">5</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s2">"standoff pilot"</span><span class="p">),</span> <span class="c1"># the same, in the coordinates of assembly(d) (by label): survives turning the part over</span> <span class="n">Wall</span><span class="p">(</span><span class="s2">"lid"</span><span class="p">,</span> <span class="s2">"XY"</span><span class="p">,</span> <span class="n">d</span><span class="o">.</span><span class="n">LID_Z</span> <span class="o">+</span> <span class="mf">1.0</span><span class="p">,</span> <span class="n">near</span><span class="o">=</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">),</span> <span class="n">radius</span><span class="o">=</span><span class="mi">4</span><span class="p">,</span> <span class="n">frame</span><span class="o">=</span><span class="s2">"assembly"</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s2">"screw boss"</span><span class="p">),</span> <span class="c1"># downward faces > 45 deg are always reported; fail=True for parts that must print</span> <span class="c1"># without supports (bridges between two walls are allowed unless bridges_ok=False)</span> <span class="n">Overhang</span><span class="p">(</span><span class="s2">"cover"</span><span class="p">,</span> <span class="n">fail</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span> <span class="c1"># material must exist (or not) in a small box: "roof is closed", "channel is clear"</span> <span class="n">Probe</span><span class="p">(</span><span class="s2">"cover"</span><span class="p">,</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">70</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">),</span> <span class="n">expect</span><span class="o">=</span><span class="s2">"solid"</span><span class="p">,</span> <span class="n">label</span><span class="o">=</span><span class="s2">"roof closed"</span><span class="p">),</span> <span class="c1"># automatic, listed only to change it: a living hinge is thin on purpose</span> <span class="n">ThinFeature</span><span class="p">(</span><span class="s2">"lid"</span><span class="p">,</span> <span class="n">ignore</span><span class="o">=</span><span class="p">[((</span><span class="mi">0</span><span class="p">,</span> <span class="mi">20</span><span class="p">,</span> <span class="mf">0.25</span><span class="p">),</span> <span class="p">(</span><span class="mi">40</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mf">0.6</span><span class="p">))]),</span> <span class="c1"># gap between two assembly parts (or part names) inside a box: the lid's sliding fit</span> <span class="n">Gap</span><span class="p">(</span><span class="s2">"lid"</span><span class="p">,</span> <span class="s2">"base"</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="n">d</span><span class="o">.</span><span class="n">CLEARANCE</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="n">d</span><span class="o">.</span><span class="n">CLEARANCE</span> <span class="o">+</span> <span class="mf">0.1</span><span class="p">,</span> <span class="n">within</span><span class="o">=</span><span class="p">((</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">30</span><span class="p">),</span> <span class="p">(</span><span class="mi">60</span><span class="p">,</span> <span class="mi">60</span><span class="p">,</span> <span class="mi">4</span><span class="p">))),</span> <span class="c1"># opt-in: fit between the assembly's pieces (overlaps, gaps, hole alignment) inside `check`</span> <span class="n">Mates</span><span class="p">(</span><span class="n">hole_tol</span><span class="o">=</span><span class="mf">0.2</span><span class="p">,</span> <span class="n">ignore</span><span class="o">=</span><span class="p">[(</span><span class="s2">"box"</span><span class="p">,</span> <span class="s2">"screw (stand-in)"</span><span class="p">)]),</span> <span class="c1"># a moving piece swept through its motion: first collision, smallest clearance, picture</span> <span class="n">Motion</span><span class="p">(</span><span class="s2">"lid"</span><span class="p">,</span> <span class="n">axis_point</span><span class="o">=</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">30</span><span class="p">,</span> <span class="mi">20</span><span class="p">),</span> <span class="n">axis_dir</span><span class="o">=</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">start_deg</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">end_deg</span><span class="o">=</span><span class="mi">110</span><span class="p">,</span> <span class="n">against</span><span class="o">=</span><span class="p">(</span><span class="s2">"box"</span><span class="p">,),</span> <span class="n">min_clearance</span><span class="o">=</span><span class="n">d</span><span class="o">.</span><span class="n">CLEARANCE</span><span class="p">),</span> <span class="n">Slide</span><span class="p">(</span><span class="s2">"drawer"</span><span class="p">,</span> <span class="n">direction</span><span class="o">=</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">distance</span><span class="o">=</span><span class="mi">60</span><span class="p">,</span> <span class="n">against</span><span class="o">=</span><span class="p">(</span><span class="s2">"case"</span><span class="p">,)),</span> <span class="p">]</span> </code></pre></div> </article> </div> <script>var tabs=__md_get("__tabs");if(Array.isArray(tabs))e:for(var set of document.querySelectorAll(".tabbed-set")){var labels=set.querySelector(".tabbed-labels");for(var tab of tabs)for(var label of labels.getElementsByTagName("label"))if(label.innerText.trim()===tab){var input=document.getElementById(label.htmlFor);input.checked=!0;continue e}}</script> <script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script> </div> <button type="button" class="md-top md-icon" data-md-component="top" hidden> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8z"/></svg> Back to top </button> </main> <footer class="md-footer"> <nav class="md-footer__inner md-grid" aria-label="Footer" > <a href="../examples/" class="md-footer__link md-footer__link--prev" aria-label="Previous: Examples"> <div class="md-footer__button md-icon"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11z"/></svg> </div> <div class="md-footer__title"> <span class="md-footer__direction"> Previous </span> <div class="md-ellipsis"> Examples </div> </div> </a> <a href="../../BEST_PRACTICES/" class="md-footer__link md-footer__link--next" aria-label="Next: Design rules (sourced)"> <div class="md-footer__title"> <span class="md-footer__direction"> Next </span> <div class="md-ellipsis"> Design rules (sourced) </div> </div> <div class="md-footer__button md-icon"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 11v2h12l-5.5 5.5 1.42 1.42L19.84 12l-7.92-7.92L10.5 5.5 16 11z"/></svg> </div> </a> </nav> <div class="md-footer-meta md-typeset"> <div class="md-footer-meta__inner md-grid"> <div class="md-copyright"> <div class="md-copyright__highlight"> MIT © KD5RYN and contributors </div> Made with <a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener"> Material for MkDocs </a> </div> </div> </div> </footer> </div> <div class="md-dialog" data-md-component="dialog"> <div class="md-dialog__inner md-typeset"></div> </div> <script id="__config" type="application/json">{"annotate": null, "base": "../..", "features": ["navigation.sections", "navigation.footer", "navigation.top", "content.code.copy", "content.tabs.link", "search.highlight"], "search": "../../assets/javascripts/workers/search.a7633da7.min.js", "tags": null, "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}, "version": null}</script> <script src="../../assets/javascripts/bundle.c21346df.min.js"></script> </body> </html>