Files
OrcaSlicer/tools/mcp/tests/ops_export_gcode.json
T
SoftFever d64e10f4dd Regroup the slicer's MCP commands and let each run from its arguments
Outside the Design tab an agent had 175 commands, 50 of them in the tool
list. There are now 118, named by what they act on (`object_`, `plate_`,
`preset_`, `filament_`, `plugin_` and so on), and 115 are listed. Each takes
its target and values in the call, acts on the selection when it names no
target and says what it acted on; an old name is refused. Printers and
system filaments install and uninstall, preferences read and write, plugins
enable, reload, uninstall and refresh, and objects reorder, with no dialog
to drive.

The Speed Dial keeps its 129 tiles under the same ids. Eight defects in the
rows these commands share with the menus are fixed. For a person: an object
row that cannot run says why instead of "Select an object first.", rows
that failed no longer claim success, Duplicate Plate can be undone, and
Refresh Plugins picked while a refresh runs now runs after it instead of
beside it.
2026-11-18 16:50:32 +08:00

104 lines
7.1 KiB
JSON

// Records what the G-code export, project_export with format gcode and a path, does: with no objects, on a plate
// not sliced, with a plate index the project lacks, after a slice that ended with an error, a success, two exports
// started back to back, and while a slice runs (started by the slice_and_preview and slice_all tiles, which return
// at once). Each case exports once, to a file named for it. A replay step returns once a short export has
// finished, so the two started back to back run one after the other; overlapping calls need two clients. Every
// call it records is optional, so a refusal is kept in result.json with its text, and each is followed by the
// reads that show what it left; the script_run steps (fixtures/ops_undo.py) list the undo snapshots taken since
// the last one. An stl export to a G-code's path with a plate the project lacks tells whether that file exists: it
// refuses with "exists" when it does, with the plate when not. Each case waits for idle first, since an export
// right after an edit is refused as slicing while the edit's background update is pending. Run it into a fresh
// --out directory (an export without overwrite refuses the file of an earlier run):
// tools/mcp/orca_mcp.py run-replay tools/mcp/tests/ops_export_gcode.json --out <new dir>
{
"orca_replay_version": "0.2.0",
"name": "ops export_gcode",
"vars": {
"benchy": "${replay_dir}/../../../resources/handy_models/3DBenchy.drc",
"undo": "${replay_dir}/fixtures/ops_undo.py"
},
"steps": [
{"tool": "app_wait", "args": {"for": "ready"}},
{"tool": "dialog_auto_answer", "args": {"rules": [{"match": "Spiral mode only works", "button": "yes"}]}},
{"tool": "project_new", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "view_set", "args": {"tab": "prepare"}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
// ---- No objects ----
{"tool": "project_export", "args": {"format": "gcode", "path": "${out_dir}/empty.gcode"}, "optional": true},
{"tool": "app_state"},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
// ---- A plate that is not sliced ----
{"tool": "object_add_primitive", "args": {"shape": "cube", "size": [20, 20, 20]}},
{"tool": "object_list", "expect": {"/total": {"eq": 1}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "project_export", "args": {"format": "gcode", "path": "${out_dir}/unsliced.gcode"}, "optional": true},
{"tool": "plate_list"},
{"tool": "app_state"},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
// ---- A plate index the project lacks ----
{"tool": "project_export", "args": {"format": "gcode", "path": "${out_dir}/no_plate.gcode", "plates": 3}, "optional": true},
{"tool": "app_state"},
// ---- A slice that ended with an error: spiral vase on a plate with two objects ----
{"tool": "object_select", "args": {"none": true}},
{"tool": "object_add_primitive", "args": {"shape": "cube", "size": [20, 20, 20]}},
{"tool": "object_arrange", "args": {"plates": "all"}},
{"tool": "plate_set_settings", "args": {"plate": 0, "values": {"spiral_mode": true}}},
{"tool": "plate_slice", "expect": {"/plates/0/outcome": {"eq": "error"}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "project_export", "args": {"format": "gcode", "path": "${out_dir}/slice_error.gcode"}, "optional": true},
{"tool": "plate_list"},
{"tool": "app_state"},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "plate_set_settings", "args": {"plate": 0, "values": {"spiral_mode": null}}},
// ---- Success, and whether the file is there when the reply comes ----
{"tool": "plate_slice", "expect": {"/plates/0/outcome": {"eq": "ok"}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "project_export", "args": {"format": "gcode", "path": "${out_dir}/ok.gcode"}, "optional": true},
{"tool": "project_export", "args": {"format": "stl", "path": "${out_dir}/ok.gcode", "plates": 999}, "optional": true},
{"tool": "plate_list"},
{"tool": "app_state"},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
// ---- Two exports back to back ----
// A modal error would show in app_state; dialog_answer closes it if one opened.
{"tool": "project_export", "args": {"format": "gcode", "path": "${out_dir}/twice_1.gcode"}, "await": false, "save_as": "twice_1", "optional": true},
{"tool": "project_export", "args": {"format": "gcode", "path": "${out_dir}/twice_2.gcode"}, "await": false, "save_as": "twice_2", "optional": true},
{"tool": "app_state"},
{"tool": "dialog_answer", "args": {"button": "ok"}, "optional": true},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "project_export", "args": {"format": "stl", "path": "${out_dir}/twice_2.gcode", "plates": 999}, "optional": true},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
// ---- While a slice runs: the slice_and_preview tile, then slice_all, both return at once ----
{"tool": "project_new", "args": {"discard_changes": true}},
{"tool": "project_import", "args": {"paths": ["${vars.benchy}"]}, "expect": {"/added": {"eq": 1}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "action_run", "args": {"id": "orca_command:slice_and_preview:orca"}},
{"tool": "project_export", "args": {"format": "gcode", "path": "${out_dir}/slicing_preview.gcode"}, "optional": true},
{"tool": "app_state"},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "plate_list"},
{"tool": "object_transform", "args": {"object": 0, "translate": [5, 0, 0]}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "action_run", "args": {"id": "orca_command:slice_all:orca"}},
{"tool": "project_export", "args": {"format": "gcode", "path": "${out_dir}/slicing_all.gcode"}, "optional": true},
{"tool": "app_state"},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "plate_list"},
{"tool": "project_export", "args": {"format": "stl", "path": "${out_dir}/slicing_preview.gcode", "plates": 999}, "optional": true},
{"tool": "project_export", "args": {"format": "stl", "path": "${out_dir}/slicing_all.gcode", "plates": 999}, "optional": true},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "project_new", "args": {"discard_changes": true}}
]
}