70 KiB
Design tab
The design of this area's sweep tests. The rules every entry follows and the grades are in TESTS.md.
The Design tab on a shared data folder
Every test here runs on an app launched with --cad, which turns the Design tab on for that run and writes nothing
to the data folder. What the Design tab reads from the folder:
- the selected printer's bed, which it draws, which sizes the plane squares a click picks to open a sketch, and
whose centre is
modeling_origin, the point the base planes pass through: (125, 125, 0) on the Generic Klipper Printer; - the Origin and Bed switches of its view (
design_show_origin,design_show_bed), whichview_setwrites, and whichcad_gui.reset_switches()sets as a new folder has them, Origin off and Bed on, for every test here; - the Commit to Plate mode (
design_commit_mode), which only a pick from the button's list writes, and no test makes one; - the Text dialog's last font and height (
cad_text_font,cad_text_height), which the dialog's OK writes and a text given no face or height takes; - the weld rule of a new sketch (
auto_close_sketch_loops), which no test writes, and the sidebar's layout, which the app saves only when it closes.
What the app keeps until it closes, beside the baseline start() puts back: the design itself, which each test and
part clears with design_new; the view's helper planes and axes (keys P and A) and its section view, which
reset_switches() turns off with the switches above; and the Design camera, which CadGui.start() sets
(reset_view()) and the replays point themselves.
A Design command that succeeds replies without ok; only a rejected rebuild replies ok false, with its error.
So a check that a call succeeded reads that its reply has no ok, and a replay step's expect gives
"/ok": {"exists": false}. undo and redo, which are not Design commands, keep their reply's own result, the
Design history's depths, which a replay step reads under /result/. The server rounds a reply's numbers for an agent (4 decimals), so the Python tests,
whose checks compute with the design's numbers (corners square to 1e-9, a replay's results equal to the live
run's to 1e-6), read them whole: CadGui and test_cad_replays set exact_numbers on their client.
So every Python test here starts with start(client) on the Generic Klipper Printer, and a replay whose checks
follow the bed selects that printer in its first steps. The only check that writes out a value the bed fixes is
cad_sketch_to_solid's 125, the Klipper bed's centre, and that replay selects the Klipper printer itself; no other
check changes with the printer. The main window is the baseline's 1600 x 900 at every start. A project a test leaves
unsaved stays in the app's auto-backup, in that test's own temporary folder, and the data folder's settings point to
it (last_backup_path): while that folder exists, as it does after the test failed, the next launch on the data
folder opens on a prompt to restore it, which orca_mcp.py launch answers No, so the test after it starts on an
empty project.
test_cad_replays
test_cad_replays.py · Python
Tests: The Design tab driven through its commands alone, in one app, one part after another:
- the six replays in
tests/,cad_sketch_to_solid,cad_sketch_edit,cad_topology_targets,cad_features,cad_docandcad_canvas, each run withreplay_run, astest_runtime_callsrunssmoke_test.json; - round_trip: that a Design session made through
tool_calland exported withreplay_exportreplays to the same part; - slow_build: that the app stays inspectable while a long Design rebuild runs off the UI thread behind the progress dialog;
- examples: that every example
tool_describe {tool}documents for the Design commands, whichtool_list {group: "Design"}lists, and forundoandredo, still runs as written.
Each replay but cad_canvas checks what it builds by volume and by what the reading commands give back, under each
reply's result; cad_canvas checks the canvas's behaviour and the design-only project's round trip. Its steps marked optional are the calls meant to be refused, which a replay cannot assert (TESTS.md, "What
the sweep does not catch"). What each builds:
cad_sketch_to_solidtakes sketches to solids: an L-bracket profile on XZ through the modeling origin with its inside corner filleted in the sketch (after an empty commit that must fail and leave the sketch open), a shelf-pin jig plate whose five holes are in its sketch, a lip sketched on the plate's top face and joined to it, one loop of the plate's sketch extruded alone, and a ring revolved about its sketch's centerline.cad_sketch_editdrives the sketch tools: the bench's hex standoff from a polygon 8 mm across the flats, a trim and an extend on crossing lines, and a plate with a chamfered and a rounded corner, two slots (one an array copy turned upright), an elliptic hole and four holes arrayed about a point, constrained from picks and from named points, with a refused constraint rolled back and one deleted.cad_topology_targetsbuilds the bench's J wall hook from what the reading commands give back: its inside corners found by convexity, M4 countersinks seated on the front face on the axes of pilot holes, the cones' kind, apex side and radii frombody_describe, the hole heights and the plate's thickness fromdesign_measure, a datum plane midway through the plate and one 70 mm up with a sketch on it, a refused tangent plane, and the back face pushed out 2 mm.cad_featuresthreads, sweeps, lofts and splits: the bench's M5 hex standoff tapped on its bore (M5 inferred from the bore) and again on the XY plane, each within the bench's volume bounds; a spring swept along a helix in round and square wire; a square-to-circle loft between XY and a datum plane 40 mm up; the loft split by that datum and its lower half cut again by XY turned over.cad_docreads and edits features as their cards do: a variable bound to an extrude, then removed, and literal edits withfeature_edit. Then it commits the design to the plate, recommits over the first object and undoes that in one step, exports STEP and reads it back into a new design, and commits two bodies both ways. Last it walks the Design history (undo/redoof an edit and of a rename), suppresses, moves and deletes features, names, hides and colours bodies, commits only the shown one, and saves and reopens the project to check that a body's name and colour were kept.cad_canvasdrives the Design view as a canvas:view_setshows the Design tab and points its camera (and refuses Prepare's and Preview's fields there), canvas and widget screenshots capture the view, a click at its centre picks the block and a right click lists the verbs for the pick, andkeyboard_pressreaches the Design panel's key hook (Shift+E opens the Extrude card, Escape with no target closes it). Last, a change made only in the Design tab marks the project modified, and reopening the saved design-only project withdiscard_changesasks nothing and names the project after its file.
The replay files are the test's input; the sweep runs none of them on its own. test_cad_failed_job stays a test of
its own, since it runs with a reply budget of 4 s.
Starts from: Each part starts from the same state, whatever the part before it left: start(client), the
baseline on the Generic Klipper Printer with 0.20mm Standard @MyKlipper and Generic PLA @System, which closes
the open dialogs and what design_cancel_tool closes in the Design tab (a card, a sketch, the Text dialog, a plane pick);
then reset_switches() on the Design tab, and Prepare shown again. So a part that fails with a dialog or a sketch
open does not fail the next one. Each part then sets its own start, given with it below.
Leaves: What examples, the last part, leaves: the project unsaved, holding the objects its two design_commit_to_plate
examples sent to the plate. The recent projects name design.3mf (cad_doc) and design_only.3mf (cad_canvas), in
the folder the run makes in its own temporary folder and prints, which also takes the replays' result.json and
files, round_trip's exported session and its run, and slow_build's two screenshots. In the folder's settings only the
Origin and Bed switches, as a new folder has them: sketch_text reads the Text dialog's last font and height and
writes neither, and the dialog_auto_answer rule cad_doc registers ends with the replay. A rerun on the same data
folder starts each part over from start() and reset_switches().
Decides by: Exits 1 when any check prints FAIL or a part breaks off: Checks.scenario records a raise, in the
part or in the reset before it, as ": runs to its end", and the next part still runs. A replay is one check,
": the replay passes", which holds when replay_run's reply has passed true; on a failure its detail names
the failed step, its arguments, and its error or the expect that missed. A replay stops at its first failed step: a
call that errors, unless the step is optional, or an expect that misses. Each part's checks follow, in the order
the parts run; the checks of round_trip, slow_build and examples print after the part's name, as "round_trip: the
exported session replays".
Part cad_sketch_to_solid · tests/cad_sketch_to_solid.json, 38 steps, 59 expects, 1 optional
Sketch to solid through the Design commands. A sketch on a base plane passes through modeling_origin. An empty
sketch_finish is refused and leaves the sketch open. A fillet is made inside the sketch. Then come extrudes (whole
sketch as a new body, one loop alone, and a sketch on a body face joined onto that body) and a revolve about the
sketch's only construction line.
Its start: the Generic Klipper Printer, which its first step after app_wait selects (preset_select {type: "printer", name: "MyKlipper 0.4 nozzle", preset_changes: "discard"}), since its checks of where the XZ sketch and
the bracket lie follow the bed; then its own project_new, window_set 1600 x 900 and design_new. On that bed the
XZ sketch's frame origin and the bracket's lowest corner are both at (125, 125, 0).
- Sketch frames: the XZ sketch reports
planeXZ with normal +Y and frame origin x 125 (exact), the Klipper bed's centre. The sketch on face 10 has frame origin z 8 ± 1e-3, x axis world −Y and y axis world +X (exact). - Sketch contents: 6 entities after drawing and 7 after
sketch_fillet. The fillet is entity 6 withreleased_constraints1 andsolve_ok. Committed, it is anarcof radius 3 ± 1e-4. Loop areas: 265.93–265.94 and 9600 ± 0.01. The plate is loop 5. Each commit'ssketch_index/featuresis checked. - Empty commit: the next
sketch_describe(nosketchargument, so it errors when no sketch is open) must list no entities. The next commit must besketch_index0. - Solids: the
solid_extrudeandsolid_revolvereplies (extrude_index,operationnew_body/join,body,bodies,loop,endblind,axis_entity4).body_mass_propertiesvolumes are within 0.03 mm³ for the jig, lip and single loop, 0.16 for the ring and ±2 for the bracket.body_describegives 11 faces with known kinds, and the bboxes run z 0–30, then 18 after the lip. The bracket's lowest x is 125 ± 1e-3.
Part cad_sketch_edit · tests/cad_sketch_edit.json, 39 steps, 54 expects, 3 optional
The sketch's own tools through the Design commands: polygon, slot, ellipse, spline, trim, extend, chamfer, fillet,
linear and circular patterns, rotate and move. It also adds constraints and dimensions from entity picks and from
named points (origin): a radius that over-constrains is rolled back and a constraint is deleted. Each result is
read back from sketch_describe and sketch_list_constraints and from the extruded solid's volume.
Its start: its own project_new, window_set 1600 x 900 and design_new. Every value it reads is in a sketch's own
coordinates or a volume, so no check depends on the printer.
- Hex standoff:
sketch_draw's shape bookkeeping (count6,first6, 7 entities). The first edge lies at x 4 ± 1e-4. The hexagon loop has area 55.4256–55.4257 and holds the bore as hole 0. Volume 630.0–630.1. - Trim/extend:
sketch_trimcuts line 0 to end at x 0 ± 1e-4, with p0 still −10.sketch_extendtakes line 2 to x 30 ± 1e-4. The sketch is then cancelled, and the next commit beingsketch_index0 shows that nothing was committed. - Plate edits: the rectangle has
dof4. The chamfer and fillet create entities 4 and 5, then there are 6 in all. Shape indices for the slot, ellipse, circle and spline, and 13 entities. Linear pattern:first_index13,added4. Rotate pivot (−10, 10) ± 1e-4. Move reports entity 11. Circular pattern:first_index17,added3,bound3. Copy 18 is centred at (22, 0) and the rotated slot's p0 x is −12, both ± 1e-4. Buildable. - Constraints: 25 before. The distance dimension is added at index 25 with an
originref andsolve_ok.equalis stored asequal_radius. After the optional radius there are 27, with item 26equal_radius. Deleting 25 removes adistanceand leaves 26 in both the live (scopelive) and the committed (scopecommitted) sketch. - Final solid: 11106.1–11106.25 mm³.
Part cad_topology_targets · tests/cad_topology_targets.json, 33 steps, 69 expects, 1 optional
Reading a body's topology and building on what it finds. It covers body_describe filters (convexity, face kinds,
direction, extreme, adjacency, paging), a fillet on an inside edge found that way, and M4 countersinks seated on a
face on a pilot hole's axis (at a cylindrical face). It also covers design_measure between faces and axes, datum planes
(midplane, offset) with a sketch on one, and a face push/pull that joins its own body.
Its start: its own project_new, window_set 1600 x 900 and design_new. It reads positions in a plane's frame,
heights and distances, none of which follows the bed's size.
- Topology reads, all ± 1e-4 or tighter:
- Two concave edges: the first is id 7, a line next to face 2, with 3 faces in total.
- After the fillet: one internal cylindrical face of radius 5.
- Facing −X: 2 faces, with face 0 of area 985.86–985.87.
- Two internal conical faces: half-angle 45°, radii 4.5 and 2.25, axes −X, 6 adjacent edges, the first convex and on face 0.
- The −z extreme is face 10.
- Paging:
faces/4present,faces/5absent,next_offset5.
- Countersinks:
off_plane5 ± 1e-4 for both. The first hasy0 and frame normal +X. - Measures, all ± 1e-4: axis to bottom face 25, at 90°; axis to axis 25; cone to front face 0 (≤ 1e-4); cone to back face 2.75; plate gap and min distance 5.
- Datums:
plane_index7 (normal −X) and 8 (origin z 70). The sketch on datum 8 is at z 70, issketch_index9, and makes body 1 spanning z 70–74. - Push/pull:
operationjoin on body 0,sketch_index−1, face 8, normal +X. Volumes 10352.82–.84 and 12689.20–.22.
Part cad_features · tests/cad_features.json, 45 steps, 59 expects, 6 optional
Threads, sweeps, lofts and plane splits through the Design commands:
- an internal thread on a bore, with its size inferred from the bore, and the same thread placed on the XY plane;
- a helix with round and square wire swept along it, both wires sketched before the first sweep, since a commit after a sweep rebuilds the sweep again (measured: the square wire's commit took 4.9 s after the round wire's sweep, under 0.3 s before it);
- a square-to-circle loft up to a datum plane;
- a split by that datum, then a split by XY flipped that keeps one side.
Its start: its own project_new, window_set 1600 x 900 and design_new. It reads positions in a plane's frame,
heights and volumes, none of which follows the bed's size. The thread on the bore is the M5 hex standoff at the
design's origin, which the Design tab puts at the bed's centre, (125, 125) on the Klipper bed.
- Thread on the bore:
thread_index3,designationM5,internal,pitch0.8 ± 1e-4,length15 ± 1e-4, one body. The body is solid at 600–614 mm³. Feature 3 is a Thread, withundo_depth3. - Thread on XY: after
undothere are 3 features. The thread is at x = y = 0 on body 0, as M5, and the volume is again 600–614. - Helix and sweeps:
helix_index0, with start tangent y 0.9968–0.9969 and z 0.0793–0.0794. The wires' sketches aresketch_index1 and 2. The round wire issweep_index3, a new body, solid, 2638–2691 mm³. The square wire issweep_index4, body 1 of 2, 1492–1524 mm³. - Loft: datum
plane_index0, sketches 1 and 2.loft_index3 is body 0, solid, 11850–11861 mm³. - Splits:
split_index4, upper body 0 and lower body 1, normal +Z, the bboxes meeting at z 20 ± 1e-3. The flipped split keeps body 1 at z 0–10 with 2 bodies, normal −Z, andundo_depth6.
Part cad_doc · tests/cad_doc.json, 83 steps, 139 expects, 0 optional
Reading and editing a Design feature as its card does: a variable bound to an extrude's distance and then removed,
and feature_edit under its own argument names and the aliases agents use (index, params, values). Handing the
design to the plate: Commit to Plate; a recommit that replaces the first object and is undone in one Prepare step;
and the bodies and assembly modes. A STEP export read back into a new design. The Design history and tree: undo/redo,
suppress, move and delete, body name, visibility and colour, and a save and reopen.
Its start: the Generic Klipper Printer, which its first step after app_wait selects (preset_select {type: "printer", name: "MyKlipper 0.4 nozzle", preset_changes: "discard"}), since it sends bodies to that printer's plate
and its project carries the printer; then its own project_new, window_set 1600 x 900 and design_new. The
objects object_list reads land on plate 0 of the 250 x 250 bed. The rule for the "Load project: unsaved changes"
prompt it sets before the reopen holds only for the replay.
- Discovery:
tool_describegivesfeature_describein group Design withaccess.read_onlytrue andfeature_editwith false. - Variables and edits: variable
h= 12 shows as bound todistanceindesign_describeand infeature_describe(params,expr,refs,used_by,editable). After unbinding and removing it,variablesis empty andboundis absent.feature_editreportschangedold/new pairs, and theindex,paramsandvaluesaliases each apply. Volumes 6000 and 9000 ± 0.01. - Plate hand-off: the commit reply names object 0 "Design Body", 1 part, body 0 sent, on the
preparetab.object_listthen shows 1 object of height 15 ± 0.01, then 20 after the recommit (which reportsreplaced0), and 15 again after one Prepare undoaction_run. The bodies and assembly commits create objects 1, 2 ("Design Body 2") and 3 ("Design Assembly", 2 parts), for a total of 4. - STEP round trip: the export has
bytes> 0 and one body.design_newclears 3 features and 1 body. Thedesign_import_stepbody's volume is 12000 ± 1.2. - History and tree:
- Undo/redo depths, with
distancegoing 15 → 10 → 15. - The rename trims to "Base", is its own undo step (
undo_depth4 → 3), and is undone and redone. - Suppress reports
changedtrue, then false, with body counts. feature_move's reply and the new feature order, then its undo.body_setname and visibility show indesign_describe. A hidden body is left out ofbodies_sentand listed inbodies_hidden.body_deleteandfeature_deletereport their counts, and their undos restore them.- A colour given as
#3080ffreads back as#3080FF.
- Undo/redo depths, with
- Reopen: after a save, a new project and an open, there are 4 features and body 1 is "Lid" with colour
#3080FF.
Part cad_canvas · tests/cad_canvas.json, 32 steps, 33 expects, 5 optional
The Design view as a canvas target: view_set on the Design tab, and its refusals of Prepare's and Preview's fields;
screenshots of the canvas and of its widget; a click that picks the block, and a right click that lists the pick's
verbs; keys reaching the Design panel's key hook (Shift+E opens the Extrude card, and Escape with no target closes
it); the project's modified flag after a change made only in the Design tab, and reopening a design-only project with
discard_changes.
Its start: its own project_new, design_new and window_set 1600 x 900, the size its clicks at (30, 30) and at
the canvas's centre are aimed in. The Design view's default camera is its iso view fitted to the block, whatever
the bed, and the project it saves carries the printer it reopens with.
- View:
view_setechoes tabdesignwith cameraiso, thendefault, thenfit_selection. After an extrude,app_statereports tabdesign,gizmonull and the project dirty. - Screenshots: the canvas and
wxGLCanvastargets give sourcecanvas, noapproximatekey and width > 0. The main window's width is > 0.widget_listfinds oneOrcaSceneCanvas. - Pick:
widget_clickreportsclickedcanvas. The right-click menu's first item matches "of Extrude".fit_selection, refused earlier with nothing picked, now succeeds. - Keys:
widget_list"Extrude dist" finds 1 node after Shift+E and 0 after Escape. The nextsolid_extrudesucceeds, its reply withoutok. - Project: after the save, not dirty, named
design_only; afterdesign_set_variable, dirty. Opening withdiscard_changesreports a project with 0 objects.app_statethen shows not dirty, the name and path match, and no dialogs are open. The variable is gone and a second body exists.
Part round_trip
That a Design-tab session made through tool_call and exported with replay_export replays to the same part. The
session includes failed calls (an empty commit, a missed hole, a fillet the kernel refuses), which the export must
leave out; a shell that replies ok false, which stays in; and face and edge ids passed with a generation, which
the export must drop. The replay runs in a new project in the same instance.
Its start: replay_export {clear: true}, so that the export holds this part's calls alone, then its own
project_new and design_new. No check depends on the printer: the checks compare with modeling_origin as
design_describe reads it, and the missed hole's x 500 is in the sketch plane's frame, off the plate on any bed. The
part breaks off when a recording call other than the three expected refusals errors, or when the thread's job fails.
- Live session:
- "a sketch on XY and the plate are centred on modeling_origin": the frame origin equals
modeling_originexactly, and the centre of mass x/y is within 1e-6 relative. - "an empty sketch_finish fails" and "a hole that misses fails as an error": any error.
- "a fillet the kernel refuses fails as an error with the kernel's reason": any error text without "Invalid arguments".
- "a shell thicker than the plate reports the rejected rebuild in its reply (ok false)":
ok is False. - "the thread is M5, inferred from the bore".
- "a sketch on XY and the plate are centred on modeling_origin": the frame origin equals
- Export: "the export leaves out the failed calls" (one
sketch_finish, nosolid_hole), "... leaves out the refused fillet and keeps the one that ran" (onesolid_fillet), "... keeps the shell" (onesolid_shell), and "the export records no generation". - Replay: "the exported session replays" (
passedtrue); "the same features" (type list) and "the same bodies and undo depth"; "the same volume and surface area" and "the same centre of mass", within 1e-6 relative of the live session.
Part slow_build
That the app stays inspectable while a long Design rebuild runs off the UI thread behind the progress dialog. The
rebuild is an M8 thread tapped 250 mm deep, 200 turns, which takes several seconds (measured: 7.7 s with other tests
running on the machine). While it runs, app_state and a main-window screenshot answer, the progress dialog is
listed and can be captured, and another Design command is refused as busy. The thread then lands as one feature.
Its start: its own project_new and design_new, and a 30 x 30 x 250 block. No check depends on the printer.
"Captures it" needs the main window wider than the progress dialog, as the baseline's 1600 x 900 is. The part breaks
off when an app_state or screenshot probe raises, or when the build is seen neither running nor ended within 300 s.
- Result: "the thread call succeeds" (the awaited result has its
thread_indexand nook) and "one thread feature and one body". - During the build, one probe runs. It fires once the build is seen running: when
widget_listshows a "Design" dialog whose class contains "Progress", or on Windows, where no windowwidget_listlists is the dialog, whendesign_describeis refused as busy. A build seen ending first fires none, which fails the three checks below.- "app_state answers during the build".
- "a window screenshot succeeds during the build": width non-zero.
- "another Design command is refused during the build": the
design_describeerror, asked after the two calls above, contains "Busy".
- Not on Windows:
- "the progress dialog is listed while it builds".
- "a screenshot of the progress dialog captures it": width non-zero and narrower than the main window.
Part examples · one check per documented example, 156 today, 6 of them skipped, and two on its inputs
That every example tool_describe {tool} documents for the Design commands, which tool_list {group: "Design"} lists,
and for undo and redo, still runs as written. Two checks hold the part to its inputs: tool_list {group: "Design"}
lists 88 commands, and at least one example of solid_extrude ran. Each example runs on a fresh empty design, with from_call arguments filled from earlier results.
Its start: before each example, what start() closes is closed as between parts (checks.close_open()), and
design_new discards the rest. Two examples send bodies to the plate with design_commit_to_plate, which places them on
the Klipper printer's 250 x 250 bed; no check reads where. The sketch_text examples give no face, so they take the
Text dialog's last one, and are checked only for running.
An example fails ("examples: :