Files
OrcaSlicer/tools/mcp/tests/ops_start_slice.json
T
SoftFever 0616068e26 Run commands, tools and the plugin API through one operations layer
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.
2026-11-12 22:06:10 +08:00

123 lines
7.2 KiB
JSON

// Records what starting a slice does through its routes, the slice_and_preview and slice_all commands run with
// run_action (they return at once) and the slice tool (the current plate, all, an index): with no objects, on
// one plate, on two plates, and with objects that fail validation (spiral vase on a plate with two objects).
// Each call starts from the Prepare tab; after it, the replay waits for idle and reads the plates' slice state,
// the tab, the notifications and the undo snapshots taken since the last read (fixtures/ops_undo.py). Every call
// it records is optional. Run it with
// tools/mcp/orca_mcp.py run-replay tools/mcp/tests/ops_start_slice.json --out <dir>
{
"orca_replay": 1,
"name": "ops start_slice",
"vars": {"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": "run_action", "args": {"id": "orca_command:slice_and_preview:orca"}, "optional": true},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "get_app_state"},
{"tool": "list_plates"},
{"tool": "set_view", "args": {"tab": "prepare"}},
{"tool": "run_action", "args": {"id": "orca_command:slice_all:orca"}, "optional": true},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "get_app_state"},
{"tool": "set_view", "args": {"tab": "prepare"}},
{"tool": "slice", "args": {}, "optional": true},
{"tool": "get_app_state"},
{"tool": "set_view", "args": {"tab": "prepare"}},
{"tool": "slice", "args": {"plates": "all"}, "optional": true},
{"tool": "get_app_state"},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
// ---- One plate ----
{"tool": "run_action", "args": {"id": "orca_command:add_primitive_cube:orca", "param": "20 20 20"}},
{"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()"}},
{"tool": "run_action", "args": {"id": "orca_command:slice_and_preview:orca"}, "optional": true},
{"tool": "get_app_state"},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "get_app_state"},
{"tool": "list_plates"},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "transform", "args": {"object": 0, "translate": [5, 0, 0]}},
{"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()"}},
{"tool": "slice", "args": {}, "optional": true},
{"tool": "get_app_state"},
{"tool": "list_plates"},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
// ---- Two plates, a cube on each ----
{"tool": "run_action", "args": {"id": "orca_command:plate_add:orca"}},
{"tool": "run_action", "args": {"id": "orca_command:plate_goto:orca", "param": "1"}},
{"tool": "select_objects", "args": {"none": true}},
{"tool": "run_action", "args": {"id": "orca_command:add_primitive_cube:orca", "param": "20 20 20"}},
{"tool": "run_action", "args": {"id": "orca_command:plate_goto:orca", "param": "0"}},
{"tool": "set_view", "args": {"tab": "prepare"}},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "list_plates", "expect": {"/total": {"eq": 2}, "/items/1/objects": {"eq": 1}}},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "run_action", "args": {"id": "orca_command:slice_and_preview:orca"}, "optional": true},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "get_app_state"},
{"tool": "list_plates"},
{"tool": "transform", "args": {"object": 0, "translate": [5, 0, 0]}},
{"tool": "set_view", "args": {"tab": "prepare"}},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "run_action", "args": {"id": "orca_command:slice_all:orca"}, "optional": true},
{"tool": "get_app_state"},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "get_app_state"},
{"tool": "list_plates"},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "transform", "args": {"object": 0, "translate": [5, 0, 0]}},
{"tool": "transform", "args": {"object": 1, "translate": [5, 0, 0]}},
{"tool": "set_view", "args": {"tab": "prepare"}},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "slice", "args": {"plates": "all"}, "optional": true},
{"tool": "get_app_state"},
{"tool": "list_plates"},
{"tool": "transform", "args": {"object": 1, "translate": [5, 0, 0]}},
{"tool": "set_view", "args": {"tab": "prepare"}},
{"tool": "run_action", "args": {"id": "orca_command:plate_goto:orca", "param": "0"}},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "slice", "args": {"plates": 1}, "optional": true},
{"tool": "get_app_state"},
{"tool": "list_plates"},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
// ---- Objects that fail validation: spiral vase on a plate with two objects ----
{"tool": "new_project", "args": {"discard_changes": true}},
{"tool": "run_action", "args": {"id": "orca_command:add_primitive_cube:orca", "param": "20 20 20"}},
{"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": "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()"}},
{"tool": "run_action", "args": {"id": "orca_command:slice_and_preview:orca"}, "optional": true},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "get_app_state"},
{"tool": "list_plates"},
{"tool": "set_view", "args": {"tab": "prepare"}},
{"tool": "run_action", "args": {"id": "orca_command:slice_all:orca"}, "optional": true},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "get_app_state"},
{"tool": "set_view", "args": {"tab": "prepare"}},
{"tool": "slice", "args": {}, "optional": true},
{"tool": "get_app_state"},
{"tool": "list_plates"},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "new_project", "args": {"discard_changes": true}}
]
}