Files
OrcaSlicer/tools/mcp/tests/ops_save_project_as.json
T
SoftFever 1ef24b7d34 Hold Speed Dial commands, MCP tools and Design tools in one command catalog
Every command takes JSON arguments and has one function for a person and for
automation: with no arguments it does what a person's pick does, and with
arguments it runs silently. The Design tab's CAD tools are commands that
call_tool runs, and they show as Speed Dial tiles on the Design tab.
2026-11-13 20:59:31 +08:00

72 lines
5.1 KiB
JSON

// Records what saving the project under a name does through its two routes, the save_project_as command run with
// run_action and a path and the save_project tool: a .3mf path, a .gcode.3mf path, a folder that does not
// exist, a file that exists (the tool without overwrite), and a project with no objects. After each it reads the
// project's name, file and unsaved state, the recent projects and the undo snapshots taken since the last read
// (fixtures/ops_undo.py), and whether the file is there: an stl export to the same path with a plate the project
// lacks refuses with "exists" when it is, with the plate when not. Every call it records is optional. Run it
// into a fresh --out directory (the commands write without overwrite, so they refuse the files of an earlier
// run):
// tools/mcp/orca_mcp.py run-replay tools/mcp/tests/ops_save_project_as.json --out <new dir>
{
"orca_replay": 1,
"name": "ops save_project_as",
"vars": {"undo": "${replay_dir}/fixtures/ops_undo.py"},
"steps": [
{"tool": "wait", "args": {"for": "ready"}},
{"tool": "new_project", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "set_view", "args": {"tab": "prepare"}},
// ---- No objects (the probes come once there is one) ----
{"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:save_project_as:orca", "args": {"path": "${out_dir}/empty_cmd.3mf"}}, "optional": true},
{"tool": "get_app_state"},
{"tool": "save_project", "args": {"path": "${out_dir}/empty_tool.3mf", "overwrite": true}, "optional": true},
{"tool": "get_app_state"},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
// ---- A .3mf path ----
{"tool": "new_project", "args": {"discard_changes": true}},
{"tool": "run_action", "args": {"id": "orca_command:add_primitive_cube:orca", "args": {"size": [20, 20, 20]}}},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "export", "args": {"format": "stl", "path": "${out_dir}/empty_cmd.3mf", "plates": 999}, "optional": true},
{"tool": "export", "args": {"format": "stl", "path": "${out_dir}/empty_tool.3mf", "plates": 999}, "optional": true},
{"tool": "get_app_state"},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "run_action", "args": {"id": "orca_command:save_project_as:orca", "args": {"path": "${out_dir}/cmd.3mf"}}, "optional": true},
{"tool": "export", "args": {"format": "stl", "path": "${out_dir}/cmd.3mf", "plates": 999}, "optional": true},
{"tool": "get_app_state"},
{"tool": "search_actions", "args": {"group": "Recent Projects"}},
{"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": "save_project", "args": {"path": "${out_dir}/tool.3mf", "overwrite": true}, "optional": true},
{"tool": "export", "args": {"format": "stl", "path": "${out_dir}/tool.3mf", "plates": 999}, "optional": true},
{"tool": "get_app_state"},
{"tool": "search_actions", "args": {"group": "Recent Projects"}},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
// ---- A .gcode.3mf path ----
{"tool": "transform", "args": {"object": 0, "translate": [5, 0, 0]}},
{"tool": "run_action", "args": {"id": "orca_command:save_project_as:orca", "args": {"path": "${out_dir}/cmd.gcode.3mf"}}, "optional": true},
{"tool": "export", "args": {"format": "stl", "path": "${out_dir}/cmd.gcode.3mf", "plates": 999}, "optional": true},
{"tool": "get_app_state"},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "save_project", "args": {"path": "${out_dir}/tool.gcode.3mf", "overwrite": true}, "optional": true},
{"tool": "export", "args": {"format": "stl", "path": "${out_dir}/tool.gcode.3mf", "plates": 999}, "optional": true},
{"tool": "get_app_state"},
// ---- A folder that does not exist ----
{"tool": "run_action", "args": {"id": "orca_command:save_project_as:orca", "args": {"path": "${out_dir}/missing/cmd.3mf"}}, "optional": true},
{"tool": "save_project", "args": {"path": "${out_dir}/missing/tool.3mf", "overwrite": true}, "optional": true},
{"tool": "get_app_state"},
// ---- A file that exists: the command to the tool's file, the tool without overwrite to the command's ----
{"tool": "run_action", "args": {"id": "orca_command:save_project_as:orca", "args": {"path": "${out_dir}/tool.3mf"}}, "optional": true},
{"tool": "save_project", "args": {"path": "${out_dir}/cmd.3mf"}, "optional": true},
{"tool": "get_app_state"},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "new_project", "args": {"discard_changes": true}}
]
}