mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-11-25 23:01:09 -05:00
A Speed Dial command, the MCP tool that does the same thing and the plugin API's preset calls now run one shared operation, so every route accepts and refuses the same states, with one wording and a code for each refusal. An import by a command or a tool is one undo step, and import_file adds geometry only. The cases where two routes behaved differently now behave the same: a project is not saved under a .gcode.3mf name, an empty project exports as .3mf but not as STL, arrange runs from any view and with a gizmo open, a mixed-colour filament slot is refused as one, a hidden preset is shown before it is selected, and a layer is refused while the Preview has none.
127 lines
9.6 KiB
JSON
127 lines
9.6 KiB
JSON
// Records what the G-code export does through its two routes, the export tool (format gcode) and the
|
|
// export_gcode command run with run_action and a path param: with no objects, on a plate not sliced, after a
|
|
// slice that ended with an error, while a slice runs (started by slice_and_preview and slice_all, which return
|
|
// at once), with a plate index the project lacks, with no param, a success, and two exports started back to back
|
|
// through each route. A replay step returns once a short export has finished, so those two 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, which both routes word alike, and each is followed by the reads that show what it
|
|
// left; the run_script 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
|
|
// (a command's JSON path param can't carry a Windows ${out_dir}, so the commands write without overwrite and
|
|
// refuse the files of an earlier run):
|
|
// tools/mcp/orca_mcp.py run-replay tools/mcp/tests/ops_export_gcode.json --out <new dir>
|
|
{
|
|
"orca_replay": 1,
|
|
"name": "ops export_gcode",
|
|
"vars": {
|
|
"benchy": "${replay_dir}/../../../resources/handy_models/3DBenchy.drc",
|
|
"undo": "${replay_dir}/fixtures/ops_undo.py"
|
|
},
|
|
"steps": [
|
|
{"tool": "wait", "args": {"for": "ready"}},
|
|
{"tool": "auto_answer_dialogs", "args": {"rules": [{"match": "Spiral mode only works", "button": "yes"}]}},
|
|
{"tool": "new_project", "args": {"discard_changes": true, "preset_changes": "discard"}},
|
|
{"tool": "set_view", "args": {"tab": "prepare"}},
|
|
{"tool": "wait", "args": {"for": "idle"}},
|
|
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
|
|
|
|
// ---- No objects ----
|
|
{"tool": "export", "args": {"format": "gcode", "path": "${out_dir}/empty_tool.gcode", "overwrite": true}, "optional": true},
|
|
{"tool": "run_action", "args": {"id": "orca_command:export_gcode:orca", "param": "${out_dir}/empty_cmd.gcode"}, "optional": true},
|
|
{"tool": "get_app_state"},
|
|
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
|
|
|
|
// ---- A plate that is not sliced ----
|
|
{"tool": "run_action", "args": {"id": "orca_command:add_primitive_cube:orca", "param": "20 20 20"}},
|
|
{"tool": "list_objects", "expect": {"/total": {"eq": 1}}},
|
|
{"tool": "wait", "args": {"for": "idle"}},
|
|
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
|
|
{"tool": "export", "args": {"format": "gcode", "path": "${out_dir}/unsliced_tool.gcode", "overwrite": true}, "optional": true},
|
|
{"tool": "run_action", "args": {"id": "orca_command:export_gcode:orca", "param": "${out_dir}/unsliced_cmd.gcode"}, "optional": true},
|
|
{"tool": "list_plates"},
|
|
{"tool": "get_app_state"},
|
|
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
|
|
|
|
// ---- A plate index the project lacks (the command takes no plate) ----
|
|
{"tool": "export", "args": {"format": "gcode", "path": "${out_dir}/noplate_tool.gcode", "overwrite": true, "plates": 3}, "optional": true},
|
|
{"tool": "get_app_state"},
|
|
|
|
// ---- No param: refused by run_action before the command runs ----
|
|
{"tool": "run_action", "args": {"id": "orca_command:export_gcode:orca"}, "optional": true},
|
|
{"tool": "get_app_state"},
|
|
|
|
// ---- A slice that ended with an error: spiral vase on a plate with two objects ----
|
|
{"tool": "select_objects", "args": {"none": true}},
|
|
{"tool": "run_action", "args": {"id": "orca_command:add_primitive_cube:orca", "param": "20 20 20"}},
|
|
{"tool": "arrange", "args": {}},
|
|
{"tool": "set_settings", "args": {"scope": "plate", "plate": 0, "values": {"spiral_mode": true}}},
|
|
{"tool": "slice", "expect": {"/plates/0/outcome": {"eq": "error"}}},
|
|
{"tool": "wait", "args": {"for": "idle"}},
|
|
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
|
|
{"tool": "export", "args": {"format": "gcode", "path": "${out_dir}/error_tool.gcode", "overwrite": true}, "optional": true},
|
|
{"tool": "run_action", "args": {"id": "orca_command:export_gcode:orca", "param": "${out_dir}/error_cmd.gcode"}, "optional": true},
|
|
{"tool": "list_plates"},
|
|
{"tool": "get_app_state"},
|
|
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
|
|
{"tool": "set_settings", "args": {"scope": "plate", "plate": 0, "values": {"spiral_mode": null}}},
|
|
|
|
// ---- Success, and whether the file is there when the reply comes ----
|
|
{"tool": "slice", "expect": {"/plates/0/outcome": {"eq": "ok"}}},
|
|
{"tool": "wait", "args": {"for": "idle"}},
|
|
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
|
|
{"tool": "export", "args": {"format": "gcode", "path": "${out_dir}/ok_tool.gcode", "overwrite": true}, "optional": true},
|
|
{"tool": "export", "args": {"format": "stl", "path": "${out_dir}/ok_tool.gcode", "plates": 999}, "optional": true},
|
|
{"tool": "run_action", "args": {"id": "orca_command:export_gcode:orca", "param": "${out_dir}/ok_cmd.gcode"}, "optional": true},
|
|
{"tool": "export", "args": {"format": "stl", "path": "${out_dir}/ok_cmd.gcode", "plates": 999}, "optional": true},
|
|
{"tool": "list_plates"},
|
|
{"tool": "get_app_state"},
|
|
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
|
|
|
|
// ---- Two exports back to back: tool and tool, command and command, tool then command ----
|
|
// A modal error would show in get_app_state; answer_dialog closes it if one opened.
|
|
{"tool": "export", "args": {"format": "gcode", "path": "${out_dir}/twice_tool_1.gcode", "overwrite": true}, "await": false, "save_as": "tool_1", "optional": true},
|
|
{"tool": "export", "args": {"format": "gcode", "path": "${out_dir}/twice_tool_2.gcode", "overwrite": true}, "await": false, "save_as": "tool_2", "optional": true},
|
|
{"tool": "get_app_state"},
|
|
{"tool": "answer_dialog", "args": {"button": "ok"}, "optional": true},
|
|
{"tool": "run_action", "args": {"id": "orca_command:export_gcode:orca", "param": "${out_dir}/twice_cmd_1.gcode"}, "await": false, "save_as": "cmd_1", "optional": true},
|
|
{"tool": "run_action", "args": {"id": "orca_command:export_gcode:orca", "param": "${out_dir}/twice_cmd_2.gcode"}, "await": false, "save_as": "cmd_2", "optional": true},
|
|
{"tool": "get_app_state"},
|
|
{"tool": "answer_dialog", "args": {"button": "ok"}, "optional": true},
|
|
{"tool": "export", "args": {"format": "gcode", "path": "${out_dir}/twice_mix_1.gcode", "overwrite": true}, "await": false, "save_as": "mix_1", "optional": true},
|
|
{"tool": "run_action", "args": {"id": "orca_command:export_gcode:orca", "param": "${out_dir}/twice_mix_2.gcode"}, "await": false, "save_as": "mix_2", "optional": true},
|
|
{"tool": "get_app_state"},
|
|
{"tool": "answer_dialog", "args": {"button": "ok"}, "optional": true},
|
|
{"tool": "wait", "args": {"for": "idle"}},
|
|
{"tool": "export", "args": {"format": "stl", "path": "${out_dir}/twice_tool_2.gcode", "plates": 999}, "optional": true},
|
|
{"tool": "export", "args": {"format": "stl", "path": "${out_dir}/twice_cmd_2.gcode", "plates": 999}, "optional": true},
|
|
{"tool": "export", "args": {"format": "stl", "path": "${out_dir}/twice_mix_2.gcode", "plates": 999}, "optional": true},
|
|
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
|
|
|
|
// ---- While a slice runs: slice_and_preview, then slice_all, both return at once ----
|
|
{"tool": "new_project", "args": {"discard_changes": true}},
|
|
{"tool": "open_files", "args": {"paths": ["${vars.benchy}"]}, "expect": {"/added": {"eq": 1}}},
|
|
{"tool": "wait", "args": {"for": "idle"}},
|
|
{"tool": "run_action", "args": {"id": "orca_command:slice_and_preview:orca"}},
|
|
{"tool": "export", "args": {"format": "gcode", "path": "${out_dir}/busy_tool.gcode", "overwrite": true}, "optional": true},
|
|
{"tool": "run_action", "args": {"id": "orca_command:export_gcode:orca", "param": "${out_dir}/busy_cmd.gcode"}, "optional": true},
|
|
{"tool": "get_app_state"},
|
|
{"tool": "wait", "args": {"for": "idle"}},
|
|
{"tool": "list_plates"},
|
|
{"tool": "transform", "args": {"object": 0, "translate": [5, 0, 0]}},
|
|
{"tool": "wait", "args": {"for": "idle"}},
|
|
{"tool": "run_action", "args": {"id": "orca_command:slice_all:orca"}},
|
|
{"tool": "run_action", "args": {"id": "orca_command:export_gcode:orca", "param": "${out_dir}/busy2_cmd.gcode"}, "optional": true},
|
|
{"tool": "export", "args": {"format": "gcode", "path": "${out_dir}/busy2_tool.gcode", "overwrite": true}, "optional": true},
|
|
{"tool": "get_app_state"},
|
|
{"tool": "wait", "args": {"for": "idle"}},
|
|
{"tool": "list_plates"},
|
|
{"tool": "export", "args": {"format": "stl", "path": "${out_dir}/busy_cmd.gcode", "plates": 999}, "optional": true},
|
|
{"tool": "export", "args": {"format": "stl", "path": "${out_dir}/busy2_cmd.gcode", "plates": 999}, "optional": true},
|
|
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
|
|
|
|
{"tool": "new_project", "args": {"discard_changes": true}}
|
|
]
|
|
}
|