Files
OrcaSlicer/tools/mcp/tests/objects_files.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

133 lines
10 KiB
JSON

// Clone, Reload from disk and Replace 3D file by index: object_clone makes three copies of object 0, which its reply
// names by their new indices beside the object copied, and the Clone dialog, opened through the object's menu, clones
// once more; object_clone with no targets copies a selected instance as a new object and names that instance;
// object_reload_from_disk takes the new mesh of a file overwritten in the output folder (written by
// fixtures/objects_files.py), and once the file is gone lists the part under missing with no file dialog;
// part_replace swaps a part's mesh for another file's and it keeps its type, filament and position, a modifier's and it
// stays a modifier, and with keep_painting turned on in the Preferences dialog a part keeps the supports painted on it.
// Run it with
// tools/mcp/orca_mcp.py run-replay tools/mcp/tests/objects_files.json --out <dir>
{
"orca_replay_version": "0.2.0",
"name": "objects files by index",
"vars": {
"files": "${replay_dir}/fixtures/objects_files.py",
"undo": "${replay_dir}/fixtures/ops_undo.py",
"box": "${replay_dir}/../../../tests/data/test_stl/ASCII/20mmbox-LF.stl",
"same_box": "${replay_dir}/../../../tests/data/test_stl/ASCII/20mmbox-CRLF.stl"
},
"steps": [
{"tool": "app_wait", "args": {"for": "ready"}},
{"tool": "project_new", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "view_set", "args": {"tab": "prepare"}},
// ---- Clone: three copies of object 0, named by their new indices, arranged on the plate ----
{"tool": "object_add_primitive", "args": {"shape": "cube", "size": [20, 20, 20]}},
{"tool": "object_select", "args": {"none": true}},
{"tool": "object_clone", "args": {"objects": [0], "count": 3, "arrange": true},
"expect": {"/objects/0/index": {"eq": 1}, "/objects/2/index": {"eq": 3}, "/objects/3": {"exists": false},
"/copied/objects/0/index": {"eq": 0}, "/copied/objects/1": {"exists": false}, "/copied/instances": {"exists": false},
"/object_count": {"eq": 4}, "/arranged": {"eq": true}}},
{"tool": "object_list", "expect": {"/outside": {"empty": true}, "/plates/0/objects/3/index": {"eq": 3},
"/plates/0/objects/4": {"exists": false}}},
// ---- The Clone dialog through the object's menu clones ----
{"tool": "view_set", "args": {"camera": "iso"}},
{"tool": "view_set", "args": {"camera": "fit_objects"}},
{"tool": "object_select", "args": {"objects": [0]}},
// The 3D view draws the arranged objects before the click, so that it finds the object under the pointer.
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "mouse_gesture", "args": {"action": "click", "button": "right", "at": {"object": 0, "spot": "top"}, "popup_item": "Clone"},
"expect": {"/ran": {"eq": "Clone"}}},
{"tool": "app_wait", "args": {"for": "dialog"}},
{"tool": "dialog_answer", "args": {"dialog": {"title": "Clone"}, "button": "ok"}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "app_state", "expect": {"/dialogs": {"empty": true}}},
{"tool": "script_run", "args": {"filename": "${vars.files}", "code": "import objects_files\nresult = objects_files.object_count()"},
"expect": {"/result/count": {"eq": 5}}},
// ---- Clone with no targets: the selected instance is copied as a new object, and the reply names it ----
{"tool": "object_set_instances", "args": {"object": 2, "count": 2}},
{"tool": "object_select", "args": {"instances": [[2, 1]]}},
{"tool": "object_clone", "args": {"arrange": true},
"expect": {"/copied/instances/0/object": {"eq": 2}, "/copied/instances/0/instance": {"eq": 1},
"/copied/instances/1": {"exists": false}, "/copied/objects": {"exists": false},
"/objects/0/index": {"eq": 5}, "/objects/1": {"exists": false}, "/object_count": {"eq": 6}}},
{"tool": "object_list", "expect": {"/plates/0/objects/5/instances/0": {"exists": true}, "/plates/0/objects/5/instances/1": {"exists": false},
"/plates/0/objects/2/instances/1": {"exists": true}}},
// ---- Reload from disk: a file overwritten with a bigger cube, then removed ----
{"tool": "project_new", "args": {"discard_changes": true}},
{"tool": "script_run", "args": {"filename": "${vars.files}", "code": "import objects_files\nresult = objects_files.import_cube(args)",
"args": {"name": "reload.stl", "size": 20}},
"expect": {"/result/import/added": {"eq": 1}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/0/mesh_volume": {"eq": 8000}}},
{"tool": "script_run", "args": {"filename": "${vars.files}", "code": "import objects_files\nresult = objects_files.write_cube(args)",
"args": {"name": "reload.stl", "size": 30}}},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "object_reload_from_disk", "args": {"objects": [0]},
"expect": {"/reloaded/0/object": {"eq": 0}, "/reloaded/0/part": {"eq": 0}, "/reloaded/0/path": {"contains": "reload.stl"},
"/reloaded/1": {"exists": false}, "/missing": {"empty": true}, "/unmatched": {"empty": true},
"/unreadable": {"exists": false}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/0/mesh_volume": {"eq": 27000}}},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"},
"expect": {"/result/taken": {"eq": ["Reload from disk"]}}},
{"tool": "script_run", "args": {"filename": "${vars.files}", "code": "import objects_files\nresult = objects_files.remove(args)",
"args": {"name": "reload.stl"}},
"expect": {"/result/removed": {"eq": true}}},
{"tool": "object_reload_from_disk", "args": {"objects": [0]},
"expect": {"/missing/0/object": {"eq": 0}, "/missing/0/part": {"eq": 0}, "/missing/0/path": {"contains": "reload.stl"},
"/reloaded": {"empty": true}}},
{"tool": "app_state", "expect": {"/dialogs": {"empty": true}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/0/mesh_volume": {"eq": 27000}}},
// ---- Replace 3D file: a part and a modifier keep their type, filament and position ----
{"tool": "project_new", "args": {"discard_changes": true}},
{"tool": "filament_add", "args": {}},
{"tool": "script_run", "args": {"filename": "${vars.files}", "code": "import objects_files\nresult = objects_files.import_cube(args)",
"args": {"name": "replace.stl", "size": 20}}},
{"tool": "part_add", "args": {"object": 0, "type": "modifier", "shape": "cylinder", "size": [10, 10]}},
{"tool": "settings_set", "args": {"type": "process", "target": "part", "object": 0, "part": 0, "values": {"extruder": 2}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/0/filament": {"eq": 2}, "/plates/0/objects/0/parts/1/type": {"eq": "modifier"},
"/plates/0/objects/0/parts/1/mesh_volume": {"lt": 7999}}},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "script_run", "args": {"filename": "${vars.files}", "code": "import objects_files\nresult = objects_files.replace_keeps(args)",
"args": {"object": 0, "part": 0, "path": "${vars.box}"}},
"expect": {"/result/reply/parts/0/object": {"eq": 0}, "/result/reply/parts/0/part": {"eq": 0},
"/result/reply/parts/0/name": {"contains": "20mmbox"}, "/result/same_id": {"eq": false},
"/result/type": {"eq": "part"}, "/result/filament": {"eq": 2}, "/result/moved": {"lt": 0.01}}},
// The new mesh keeps the old one's place in its file: the cylinder was made centred, the box file's corner is at its
// origin, so the modifier moves by that difference.
{"tool": "script_run", "args": {"filename": "${vars.files}", "code": "import objects_files\nresult = objects_files.replace_keeps(args)",
"args": {"object": 0, "part": 1, "path": "${vars.box}"}},
"expect": {"/result/reply/parts/0/part": {"eq": 1}, "/result/reply/part_info/mesh_volume": {"eq": 8000},
"/result/type": {"eq": "modifier"}, "/result/same_filament": {"eq": true}}},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"},
"expect": {"/result/taken": {"eq": ["Replace with 3D file", "Replace with 3D file"]}}},
// ---- Replace 3D file with keep_painting on: the supports painted on the part stay ----
{"tool": "project_new", "args": {"discard_changes": true}},
{"tool": "script_run", "args": {"filename": "${vars.files}", "code": "import objects_files\nresult = objects_files.import_cube(args)",
"args": {"name": "painted.stl", "size": 20}}},
{"tool": "view_set", "args": {"camera": "front"}},
{"tool": "view_set", "args": {"camera": "fit_objects"}},
{"tool": "object_select", "args": {"objects": [0]}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "widget_click", "args": {"target": {"gizmo": "FdmSupports"}}, "expect": {"/active": {"eq": true}}},
{"tool": "widget_click", "args": {"target": {"imgui_name": "Fill"}}},
{"tool": "mouse_gesture", "args": {"at": {"object": 0, "spot": "front"}}},
{"tool": "widget_click", "args": {"target": {"imgui": "Done"}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/0/painted/supports/enforcers": {"gt": 0}}},
{"tool": "window_open", "args": {"window": "preferences", "tab": "developer", "key": "keep_painting"}, "await": false, "save_as": "prefs"},
{"tool": "widget_click", "args": {"target": {"name": "keep_painting", "within": "Preferences"}}},
{"tool": "dialog_answer", "args": {"dialog": {"title": "Preferences"}, "button": "close"}},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.prefs}"}},
{"tool": "preferences_get", "args": {"keys": ["keep_painting"]}, "expect": {"/items/0/value": {"eq": true}}},
{"tool": "part_replace", "args": {"object": 0, "part": 0, "path": "${vars.same_box}"},
"expect": {"/parts/0/name": {"contains": "20mmbox"}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/0/painted/supports/enforcers": {"gt": 0}}},
{"tool": "project_new", "args": {"discard_changes": true}}
]
}