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

119 lines
7.7 KiB
JSON

// Records what object_set_instances with a count does: nothing selected, one object,
// two objects, one instance of an object, a part, counts of 1, 2 written as text, 0, negative, past 1000, a
// fraction and a word, an object with an instance that is not printable, a cut object, and its obj_set_instances
// tile (it opens its dialog, which the replay cancels). After each it reads the objects' instances and the undo
// snapshots taken since the last read (fixtures/ops_undo.py), and once runs undo to show the change is one
// step. Every call it records is optional. Run it with
// tools/mcp/orca_mcp.py run-replay tools/mcp/tests/ops_set_instance_count.json --out <dir>
{
"orca_replay_version": "0.2.0",
"name": "ops set_instance_count",
"vars": {"undo": "${replay_dir}/fixtures/ops_undo.py"},
"steps": [
{"tool": "app_wait", "args": {"for": "ready"}},
{"tool": "project_new", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "window_set", "args": {"size": [1600, 900]}},
{"tool": "view_set", "args": {"tab": "prepare"}},
{"tool": "object_add_primitive", "args": {"shape": "cube", "size": [20, 20, 20]}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "object_list", "expect": {"/total": {"eq": 1}}},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
// ---- Nothing selected ----
{"tool": "object_select", "args": {"none": true}},
{"tool": "object_set_instances", "args": {"count": 3}, "optional": true},
{"tool": "object_list"},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
// ---- One object: 3, undone, then 1 ----
{"tool": "object_select", "args": {"objects": [0]}},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "object_set_instances", "args": {"count": 3}, "optional": true},
{"tool": "object_list"},
{"tool": "app_state"},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "action_run", "args": {"id": "orca_command:undo:orca"}},
{"tool": "object_list"},
{"tool": "object_select", "args": {"objects": [0]}},
{"tool": "object_set_instances", "args": {"count": 3}, "optional": true},
{"tool": "object_set_instances", "args": {"count": " 2 "}, "optional": true},
{"tool": "object_list"},
{"tool": "object_set_instances", "args": {"count": 1}, "optional": true},
{"tool": "object_list"},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
// ---- Counts it refuses ----
{"tool": "object_select", "args": {"objects": [0]}},
{"tool": "object_set_instances", "args": {"count": 0}, "optional": true},
{"tool": "object_set_instances", "args": {"count": -2}, "optional": true},
{"tool": "object_set_instances", "args": {"count": 1001}, "optional": true},
{"tool": "object_set_instances", "args": {"count": 2.5}, "optional": true},
{"tool": "object_set_instances", "args": {"count": "three"}, "optional": true},
{"tool": "object_list"},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
// ---- Two objects selected, one instance of an object, a part ----
{"tool": "object_select", "args": {"none": true}},
{"tool": "object_add_primitive", "args": {"shape": "cylinder", "size": [20, 10]}},
{"tool": "object_arrange", "args": {"plates": "all"}},
{"tool": "object_select", "args": {"objects": [0, 1]}},
{"tool": "object_set_instances", "args": {"count": 2}, "optional": true},
{"tool": "object_list"},
{"tool": "object_select", "args": {"objects": [0]}},
{"tool": "object_set_instances", "args": {"count": 2}, "optional": true},
{"tool": "object_select", "args": {"instances": [[0, 1]]}},
{"tool": "object_set_instances", "args": {"count": 4}, "optional": true},
{"tool": "object_list"},
{"tool": "part_add", "args": {"object": 1, "type": "modifier", "shape": "cube", "size": [5, 5, 5]}},
{"tool": "object_select", "args": {"parts": [[1, 1]]}},
{"tool": "object_set_instances", "args": {"count": 2}, "optional": true},
{"tool": "object_list"},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
// ---- An instance that is not printable (the cylinder back to one instance, made not printable as the
// object list's Printable column does) ----
{"tool": "object_select", "args": {"objects": [1]}},
{"tool": "object_set_instances", "args": {"count": 1}},
{"tool": "widget_click", "args": {"target": {"row": "Plate 1>Cylinder", "column": "Printable"}}},
{"tool": "object_list", "expect": {"/plates/0/objects/1/instances/0/printable": {"eq": false}}},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "object_select", "args": {"objects": [1]}},
{"tool": "object_set_instances", "args": {"count": 2}, "optional": true},
{"tool": "action_run", "args": {"id": "orca_command:obj_set_instances:orca"}, "optional": true},
{"tool": "object_list"},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "widget_click", "args": {"target": {"row": "Plate 1>Cylinder", "column": "Printable"}}},
{"tool": "object_list", "expect": {"/plates/0/objects/1/instances/0/printable": {"eq": true}}},
// ---- The tile: its dialog opens, and is cancelled ----
{"tool": "object_select", "args": {"objects": [1]}},
{"tool": "action_run", "args": {"id": "orca_command:obj_set_instances:orca"}, "await": false, "save_as": "dialog", "optional": true},
{"tool": "app_state"},
{"tool": "dialog_answer", "args": {"button": "cancel"}, "optional": true},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.dialog}"}, "optional": true},
{"tool": "object_list"},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
// ---- A cut object: a cube cut at 10 mm with a connector, which keeps the halves linked ----
{"tool": "project_new", "args": {"discard_changes": true}},
{"tool": "view_set", "args": {"tab": "prepare", "camera": "top"}},
{"tool": "object_add_primitive", "args": {"shape": "cube", "size": [20, 20, 20]}},
{"tool": "object_select", "args": {"objects": [0]}},
{"tool": "widget_click", "args": {"target": {"gizmo": "Cut"}}, "expect": {"/active": {"eq": true}}},
{"tool": "widget_set_value", "args": {"target": {"imgui_name": "move_Z"}, "value": 10}},
{"tool": "widget_click", "args": {"target": {"imgui": "Add connectors"}}},
{"tool": "mouse_gesture", "args": {"at": {"object": 0, "spot": "top"}, "check": "point"}},
{"tool": "widget_click", "args": {"target": {"imgui": "Confirm connectors"}}},
{"tool": "widget_click", "args": {"target": {"imgui": "Perform cut"}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "object_list", "expect": {"/total": {"eq": 2}, "/plates/0/objects/0/parts/1": {"exists": true}}},
{"tool": "object_select", "args": {"objects": [0]}},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "object_set_instances", "args": {"count": 2}, "optional": true},
{"tool": "object_list"},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "project_new", "args": {"discard_changes": true}}
]
}