Mark names as code in the MCP tool descriptions

Agents can tell an argument or a reply field from an English word in every tool description. The
server instructions say what the Speed Dial is, a call held by a dialog says how to run it without
asking next time, and object_add_text and object_add_svg say what they reply.
This commit is contained in:
SoftFever committed 2026-11-22 22:01:16 +08:00
1 parent d3f57df99f
commit 3283fa0016
28 files changed
+1141 -1067

No files matched your search

+10 -5
View File
@@ -116,9 +116,10 @@ job, that a call with exactly a Speed Dial action's arguments may ask as a perso
runs from its arguments, say how a gizmo opens and is
driven (and that `gizmo_pick_file` only stands in for a file picker inside one, since its name draws agents to
it for any gizmo work), that the camera turns with `view_set` rather than a drag, and which indices are 0-based.
They say what the expected ids are (`object_id`, `part_id` and the `*_ids` lists: optional guards, refusing a call
whose index now names another object or part), once, where each of the many schemas that take one only names it.
What one command's description says, such as how `recording_start` records, stays there.
They say what the Speed Dial is, the app's command palette, since descriptions name it without saying, and what
the expected ids are (`object_id`, `part_id` and the `*_ids` lists: optional guards, refusing a call whose index
now names another object or part), once, where each of the many schemas that take one only names it. What one
command's description says, such as how `recording_start` records, stays there.
## Security, token and discovery
@@ -314,7 +315,9 @@ hidden but stays on top until its modal loop returns, which on a busy machine ca
so a hidden wx dialog on top holds no call. Its note says how to answer the topmost dialog:
`dialog_answer` for a wx dialog or a native message box whose buttons are listed, a person for any
other dialog marked `native: true` (a picker, or any native dialog on macOS), which `dialog_answer`
can't press.
can't press. It ends with how the next such call runs without asking, so that an agent learns it from the call
that asked: `silent: true` where the command's schema takes it, else the dialog's answer given as an argument. A
call that gave `silent` and still asked gets no advice, since its command's dialog always opens.
On macOS a file picker, folder picker or message box pauses wx's pending events while it is open
(`wxCFEventLoopPauseIdleEvents` in its `ShowModal()`), and `CallAfter` closures with them, so behind
@@ -745,7 +748,9 @@ its schema where the command is registered, and the core gives the journal its c
operation's own arguments, are kept as written.
Descriptions keep one order: what the tool does, the arguments that change it, `Reply:` with the
fields it has, then edge cases; a long one puts each case on a line of its own (the types and targets
fields it has, then edge cases. They mark as code the names an agent passes or reads (arguments, reply
fields, commands, and calls such as `app_wait {for: "idle"}`), so that a sentence using a field's name as a
word still parses: "unless `silent` is true"; a generated list of names marks each one; a long one puts each case on a line of its own (the types and targets
of `settings_get` and `settings_set`, `widget_click`'s web pages). What several tools share is written once,
since every session loads the whole tool list: the locator grammar in `widget_list`'s description,
which hands out the refs, each `target` giving two examples and pointing there; the paging shape, that a
+16 -8
View File
@@ -403,27 +403,35 @@ ToolResult McpCore::run(const NativeCommand& def, const nlohmann::json& args, co
return ToolResult::ok(std::move(out));
};
const std::string running_note = "The call is still running and will finish on its own; do not retry it. "
"Use app_wait {for:\"job\", job:\"" + job + "\"} for its result.";
"Use `app_wait {for:\"job\", job:\"" + job + "\"}` for its result.";
// dialog_answer presses a native message box by the buttons ModalTracker lists for it, but not a
// picker, nor a dialog while it holds the UI thread (macOS), so their note asks for a person.
// picker, nor a dialog while it holds the UI thread (macOS), so their note asks for a person. A note ends with how
// the next such call can run without asking, so that an agent learns it from the one that asked; a call that gave
// silent and still asks is of a command whose description says the dialog always opens.
const bool takes_silent = def.input_schema.contains("properties") && def.input_schema["properties"].contains("silent");
const std::string ask_less = args.contains("silent") ? std::string() :
takes_silent ? " Next time, `silent: true` runs it without asking." :
" Next time, give the dialog's answer as an argument where the schema has one, "
"so the call doesn't ask.";
auto blocked = [&](nlohmann::json dialogs, bool ui_held) {
std::string note;
const bool native = topmost_dialog_is_native(dialogs);
const bool pressable = native && !ui_held && !dialogs.back().value("buttons", nlohmann::json::array()).empty();
if (pressable) {
note = "The call is waiting on a native message box and continues after it closes; do not retry it. Answer it "
"with dialog_answer and one of its buttons, then app_wait {for:\"job\", job:\"" + job + "\"}.";
"with `dialog_answer` and one of its buttons, then `app_wait {for:\"job\", job:\"" + job + "\"}`.";
} else if (native) {
note = "The call is waiting on a native dialog, which only a person can answer (dialog_answer can't); do not retry it. ";
note = "The call is waiting on a native dialog, which only a person can answer (`dialog_answer` can't); do not "
"retry it. ";
if (ui_held)
note += "Until it closes, tools that need the UI thread fail. ";
note += "Once it is answered, app_wait {for:\"job\", job:\"" + job +
"\"}. Register dialog_auto_answer before a step that opens a native dialog.";
note += "Once it is answered, `app_wait {for:\"job\", job:\"" + job +
"\"}`. Register `dialog_auto_answer` before a step that opens a native dialog.";
} else {
note = "The call is waiting on a dialog and continues after it closes; do not retry it. "
"Answer the dialog (widget_list, dialog_answer), then app_wait {for:\"job\", job:\"" + job + "\"}.";
"Answer the dialog (`widget_list`, `dialog_answer`), then `app_wait {for:\"job\", job:\"" + job + "\"}`.";
}
return envelope("blocked_by_dialog", {{"dialogs", std::move(dialogs)}, {"note", note}});
return envelope("blocked_by_dialog", {{"dialogs", std::move(dialogs)}, {"note", note + ask_less}});
};
if (!acquire_slot())
return finish(envelope("running", {{"note", running_note}}));
+41 -42
View File
@@ -13,53 +13,52 @@ namespace {
// relies on and no one command's description can say once for all: what a command's own description says stays there.
const char* kInstructions =
"OrcaSlicer, a 3D-printing slicer, driven through its GUI.\n"
"Workflow: app_state (ready? which presets, plates, dialogs?) -> act -> check with object_list, plate_list, "
"settings_get, plate_slice's reply or plate_slice_stats; window_screenshot only for what they do not report.\n"
"Workflow: `app_state` (ready? which presets, plates, dialogs?) -> act -> check with `object_list`, `plate_list`, "
"`settings_get`, `plate_slice`'s reply or `plate_slice_stats`; `window_screenshot` only for what they do not report.\n"
"Finding what to call:\n"
"- Commands: tools/list by place (named place_verb: object_mirror); tool_list the rest (the Design tab's, menu "
"items with no arguments, plugin operations as plugin.<plugin>.<name>) for tool_call. tool_describe {tool} gives "
"a manual, read before tool_call; a parameter's values_from names the tools listing its values.\n"
"- Settings: settings_list_pages {type} lists a tab's pages, settings_list {type, where} a page's settings, what "
"each does, settings_get {keys} named ones.\n"
"- action_list {section?} lists Speed Dial actions; script_list_api {within?} orca's API by module or class, "
"script_describe_api {name} an entry.\n"
"- Commands: `tools/list` by place (named place_verb: `object_mirror`); `tool_list` the rest (the Design tab's, menu "
"items with no arguments, plugin operations as `plugin.<plugin>.<name>`) for `tool_call`. `tool_describe {tool}` "
"gives a manual, read before `tool_call`; a parameter's `values_from` names the tools listing its values.\n"
"- Settings: `settings_list_pages {type}` lists a tab's pages, `settings_list {type, where}` a page's settings, what "
"each does, `settings_get {keys}` named ones.\n"
"- `action_list {section?}` lists the actions of the Speed Dial, the app's command palette; "
"`script_list_api {within?}` orca's API by module or class, `script_describe_api {name}` an entry.\n"
"Running the session, dialogs, replays and scripts:\n"
"- A call that takes long or opens a dialog returns {status:\"running\"|\"blocked_by_dialog\", job}. It keeps "
"running: never retry it. Answer dialogs with dialog_answer (see app_state.dialogs), then app_wait {for:\"job\"}. A "
"native message box (native: true) takes dialog_answer with one of its listed buttons; a file or folder picker, "
"or a native dialog with no buttons listed (any on macOS), can't: register dialog_auto_answer before the step "
"that opens one.\n"
"- During an operation (slicing, exporting, arranging, another job) other changes are refused: app_wait or "
"job_cancel.\n"
"- replay_export saves this session's calls as a replay that replay_run runs.\n"
"- script_run runs Python against orca.host, the plugin API, to compute over "
"meshes and settings and call tools (orca.host.tools); its file, program, thread and network use is restricted "
"unless app_state.python.scripts_unrestricted.\n"
"- A call that takes long or opens a dialog returns `{status:\"running\"|\"blocked_by_dialog\", job}`. It keeps "
"running: never retry it. Answer dialogs with `dialog_answer` (see `app_state.dialogs`), then "
"`app_wait {for:\"job\"}`. A native message box (`native: true`) takes `dialog_answer` with one of its listed "
"buttons; a file or folder picker, or a native dialog with no buttons listed (any on macOS), can't: register "
"`dialog_auto_answer` before the step that opens one.\n"
"- During an operation (slicing, exporting, arranging, another job) other changes are refused: `app_wait` or "
"`job_cancel`.\n"
"- `replay_export` saves this session's calls as a replay that `replay_run` runs.\n"
"- `script_run` runs Python against `orca.host`, the plugin API, to compute over meshes and settings and call tools "
"(`orca.host.tools`); its file, program, thread and network use is restricted unless "
"`app_state.python.scripts_unrestricted`.\n"
"Acting on project data by index and name, JSON in and out; prefer these:\n"
"- A call with exactly a Speed Dial action's arguments (project_export {format:\"gcode\"}) may ask in a dialog or "
"act on the selection, as a person's pick does. Any other call, with silent: true where a "
"schema takes it, runs from its arguments; a dialog it still opens (preset_export's always) is in its "
"description.\n"
"- Objects, parts and plates are 0-based, as object_list and plate_list number them; filament slots and Preview "
"- A call with exactly a Speed Dial action's arguments (`project_export {format:\"gcode\"}`) may ask in a dialog or "
"act on the selection, as a person's pick does. Any other call, with `silent: true` where a schema takes it, runs "
"from its arguments; a dialog it still opens (`preset_export`'s always) is in its description.\n"
"- Objects, parts and plates are 0-based, as `object_list` and `plate_list` number them; filament slots and Preview "
"layers are 1-based.\n"
"- object_id, part_id and the *_ids lists are optional guards, the ids object_list reports: a call whose index now "
"names another object or part is refused.\n"
"- Lists come in pages: {items, offset, total}, next_offset while more remain (call again with it); object_list "
"has plates and outside for items.\n"
"- Paths are absolute; an output replaces a file only with overwrite: true.\n"
"- `object_id`, `part_id` and the `*_ids` lists are optional guards, the ids `object_list` reports: a call whose "
"index now names another object or part is refused.\n"
"- Lists come in pages: `{items, offset, total}`, `next_offset` while more remain (call again with it); "
"`object_list` has `plates` and `outside` for items.\n"
"- Paths are absolute; an output replaces a file only with `overwrite: true`.\n"
"Driving the GUI, for what those do not reach or to see what a person sees:\n"
"- action_run runs a Speed Dial action by id: a command's as a call with its arguments does; a "
"plate, a recent project, a plugin's script or page as a person's pick does.\n"
"- widget_list lists widgets, menus, 3D toolbar items, gizmos, ImGui items and web page elements with refs; "
"widget_click / widget_set_value / keyboard_press / mouse_gesture act on its refs (good across later listings) or "
"on the locators its description lists.\n"
"- window_list lists the open windows with refs: a window's ref as the target of window_screenshot captures it, "
"of widget_list lists it alone, and of window_set sizes, moves or raises it.\n"
"- Gizmos (Cut, Text, SVG, painting...): widget_click {target: {gizmo: \"Cut\"}} opens one; its panel's fields and "
"buttons are ImGui items for widget_set_value / widget_click, and painting is a mouse_gesture drag from the "
"object. Move the camera with view_set, never a drag, which follows the user's mouse settings. gizmo_pick_file "
"stands in for a file picker inside an open gizmo.\n"
"- window_screenshot returns a downscaled image plus the full-size PNG path; target \"canvas\" is the 3D view.";
"- `action_run` runs a Speed Dial action by id: a command's as a call with its arguments does; a plate, a recent "
"project, a plugin's script or page as a person's pick does.\n"
"- `widget_list` lists widgets, menus, 3D toolbar items, gizmos, ImGui items and web page elements with refs; "
"`widget_click` / `widget_set_value` / `keyboard_press` / `mouse_gesture` act on its refs (good across later "
"listings) or on the locators its description lists.\n"
"- `window_list` lists the open windows with refs: a window's ref as the target of `window_screenshot` captures it, "
"of `widget_list` lists it alone, and of `window_set` sizes, moves or raises it.\n"
"- Gizmos (Cut, Text, SVG, painting...): `widget_click {target: {gizmo: \"Cut\"}}` opens one; its panel's fields "
"and buttons are ImGui items for `widget_set_value` / `widget_click`, and painting is a `mouse_gesture` drag from "
"the object. Move the camera with `view_set`, never a drag, which follows the user's mouse settings. "
"`gizmo_pick_file` stands in for a file picker inside an open gizmo.\n"
"- `window_screenshot` returns a downscaled image plus the full-size PNG path; `target: \"canvas\"` is the 3D view.";
} // namespace
+8 -8
View File
@@ -246,28 +246,28 @@ std::vector<Property> target_props(unsigned kinds, bool one)
{
std::vector<Property> out;
if (one) {
out.emplace_back("object", json{{"type", "integer"}, {"minimum", 0}, {"description", "Object index (object_list)."}});
out.emplace_back("object", json{{"type", "integer"}, {"minimum", 0}, {"description", "Object index (`object_list`)."}});
out.emplace_back("object_id", expected_id_prop("object"));
if (kinds & kInstances)
out.emplace_back("instance", json{{"type", "integer"}, {"minimum", 0}, {"description", "An instance of the object (object_list)."}});
out.emplace_back("instance", json{{"type", "integer"}, {"minimum", 0}, {"description", "An instance of the object (`object_list`)."}});
if (kinds & kParts) {
out.emplace_back("part", json{{"type", "integer"}, {"minimum", 0}, {"description", "A part of the object (object_list)."}});
out.emplace_back("part", json{{"type", "integer"}, {"minimum", 0}, {"description", "A part of the object (`object_list`)."}});
out.emplace_back("part_id", expected_id_prop("part"));
}
return out;
}
if (kinds & kObjects) {
out.emplace_back("objects", array_prop({{"type", "integer"}}, "Object indices."));
out.emplace_back("object_ids", array_prop({{"type", "integer"}}, "Optional guard: the objects' ids in object_list, one each."));
out.emplace_back("object_ids", array_prop({{"type", "integer"}}, "Optional guard: the objects' ids in `object_list`, one each."));
}
if (kinds & kInstances) {
out.emplace_back("instances", array_prop({{"type", "array"}}, "[[object, instance], ...]"));
out.emplace_back("instance_object_ids", array_prop({{"type", "integer"}}, "Optional guard: the ids in object_list of the "
out.emplace_back("instances", array_prop({{"type", "array"}}, "`[[object, instance], ...]`"));
out.emplace_back("instance_object_ids", array_prop({{"type", "integer"}}, "Optional guard: the ids in `object_list` of the "
"instances' objects, one each."));
}
if (kinds & kParts) {
out.emplace_back("parts", array_prop({{"type", "array"}}, "[[object, part], ...]"));
out.emplace_back("part_ids", array_prop({{"type", "integer"}}, "Optional guard: the parts' ids in object_list, one each."));
out.emplace_back("parts", array_prop({{"type", "array"}}, "`[[object, part], ...]`"));
out.emplace_back("part_ids", array_prop({{"type", "integer"}}, "Optional guard: the parts' ids in `object_list`, one each."));
}
return out;
}
+16 -16
View File
@@ -214,13 +214,13 @@ void register_action_tools(CommandCatalog& catalog)
catalog.add(inspect_tool(
"action_list", L("List Speed Dial actions"),
"List everything the Speed Dial can run, by section and title: built-in commands (slice, export, views, object "
"operations, plates, calibration wizards, help), recent projects, plugin scripts and pages. Each entry has an id for "
"action_run, its section (where the Speed Dial lists it), a description, the command's key for a built-in command, "
"and, when it takes arguments, their input_schema. section keeps them to one of the Speed Dial's sections, which are not "
"tool_list's groups; one no action is in is refused with the sections there are, but Recent Projects and Design "
"list nothing while there are no recent projects or the Design tab is not shown. include_settings also lists "
"settings (each jumps to that setting in the sidebar; use settings_get / settings_set to read or change values).",
object_schema({{"section", prop("string", "Only this Speed Dial section, in any case, as an entry's section names it, "
"operations, plates, calibration wizards, help), recent projects, plugin scripts and pages. Each entry has an `id` for "
"`action_run`, its `section` (where the Speed Dial lists it), a `description`, the `command` of a built-in "
"command, and, when it takes arguments, their `input_schema`. `section` keeps them to one of the Speed Dial's sections, which are not "
"`tool_list`'s groups; one no action is in is refused with the sections there are, but Recent Projects and Design "
"list nothing while there are no recent projects or the Design tab is not shown. `include_settings` also lists "
"settings (each jumps to that setting in the sidebar; use `settings_get` / `settings_set` to read or change values).",
object_schema({{"section", prop("string", "Only this Speed Dial section, in any case, as an entry's `section` names it, "
"e.g. \"Object\", \"View\", \"Slice & Export\".")},
{"include_settings", prop("boolean", "Also list settings (thousands). Default false.")},
{"limit", {{"type", "integer"}, {"minimum", 1}, {"maximum", 200}, {"description", "Default 50."}}},
@@ -236,19 +236,19 @@ void register_action_tools(CommandCatalog& catalog)
NativeCommand run = mutate_tool(
"action_run", L("Run a Speed Dial action"),
"Run one action by the id action_list returned (orca_command:view_front:orca, or the name inside it, view_front), "
"with args, the command's arguments, when it takes some (its input_schema). A command's action (action_list names "
"Run one action by the id `action_list` returned (`orca_command:view_front:orca`, or the name inside it, `view_front`), "
"with `args`, the command's arguments, when it takes some (its `input_schema`). A command's action (`action_list` names "
"the command) runs the command as a call with the action's arguments does: an action that asks in a dialog asks, "
"and the call returns blocked_by_dialog; answer it with dialog_answer, or, for a native one it can't press (a file "
"picker), register dialog_auto_answer before the call. Such an action takes no args, or exactly its own; to run a "
"and the call returns `blocked_by_dialog`; answer it with `dialog_answer`, or, for a native one it can't press (a file "
"picker), register `dialog_auto_answer` before the call. Such an action takes no `args`, or exactly its own; to run a "
"command without asking, call it with its arguments (an absolute path skips a file dialog). Go to layer and Go to "
"tab take their value alone ({\"percent\": 50}, {\"tab\": \"preview\"}), and a Design command's own action takes "
"the command's arguments. An action that starts a background job (obj_arrange, obj_orient) completes when the job "
"tab take their value alone (`{\"percent\": 50}`, `{\"tab\": \"preview\"}`), and a Design command's own action takes "
"the command's arguments. An action that starts a background job (`obj_arrange`, `obj_orient`) completes when the job "
"ends. An action that does nothing (no object selected) is an error. Some commands add what they did to the reply "
"(the order object_order leaves, the object object_assemble made). The other actions (plates, recent projects, "
"(the order `object_order` leaves, the object `object_assemble` made). The other actions (plates, recent projects, "
"plugin scripts and pages, settings) run only here.",
object_schema({{"id", prop("string", "Action id from action_list, or the name inside it.")},
{"args", {{"type", "object"}, {"description", "The command's arguments, as its input_schema gives them."}}}},
object_schema({{"id", prop("string", "Action id from `action_list`, or the name inside it.")},
{"args", {{"type", "object"}, {"description", "The command's arguments, as its `input_schema` gives them."}}}},
{"id"}),
[](const json& args, ToolContext& ctx) {
std::string id = arg_string(args, "id");
+14 -12
View File
@@ -376,8 +376,8 @@ struct ManualBuilder
bool classify;
bool complete = true;
// The value `X` of "Type X:" or "Target X:" that starts `description`, when it is one of the command's own `type`
// or `target` values: the parameter goes with it.
// The value `X` of "Type X:" or "Target X:" that starts `description`, X marked as code or not, when it is one of
// the command's own `type` or `target` values: the parameter goes with it.
json goes_with(const std::string& description) const
{
for (const char* arg : {"type", "target"}) {
@@ -389,7 +389,9 @@ struct ManualBuilder
const std::size_t colon = description.find(':', lead.size());
if (colon == std::string::npos)
continue;
const std::string value = description.substr(lead.size(), colon - lead.size());
std::string value = description.substr(lead.size(), colon - lead.size());
if (value.size() > 2 && value.front() == '`' && value.back() == '`')
value = value.substr(1, value.size() - 2);
// A plugin's schema may give the property as a boolean subschema, which lists no values.
const auto props = command.input_schema.find("properties");
if (props == command.input_schema.end() || !props->is_object())
@@ -651,8 +653,8 @@ void register_api_tools(CommandCatalog& catalog, const std::string& design_index
"tool_list", L("List more tools"),
"The commands the tool list does not show, each with what it does: the Design tab's (group Design, with the CAD "
"feature on, each under its heading), the menu items that take no arguments (in their places' groups), and the "
"operations plugins offer (group Plugins, plugin.<plugin>.<name>). The reply says how to read a command's manual "
"and how to run one. group keeps one group's: a group whose commands the tool list all shows "
"operations plugins offer (group Plugins, `plugin.<plugin>.<name>`). The reply says how to read a command's manual "
"and how to run one. `group` keeps one group's: a group whose commands the tool list all shows "
"gives none and a note, and Design while this run leaves its commands out is refused saying why." +
design_index,
object_schema({{"group", prop("string", "Only this group's commands, its whole name in any case: Tools and actions; The "
@@ -660,8 +662,8 @@ void register_api_tools(CommandCatalog& catalog, const std::string& design_index
"Printers and prints; Plugins, with the operations plugins offer; View and "
"windows; Recordings, replays and scripts; Driving the GUI; or Design (the Design "
"tab's, with the CAD feature on). A command outside Design is in the group of the "
"place its name starts with (object_delete in Objects), but for window_screenshot "
"and window_save_screenshot, which are in Recordings, replays and scripts. A name "
"place its name starts with (`object_delete` in Objects), but for `window_screenshot` "
"and `window_save_screenshot`, which are in Recordings, replays and scripts. A name "
"no command's group has is refused with the groups there are, and Design, "
"when this run leaves the Design tab's commands out, with the reason.")}}),
[](const json& args, ToolContext&) {
@@ -671,12 +673,12 @@ void register_api_tools(CommandCatalog& catalog, const std::string& design_index
catalog.add(inspect_tool(
"tool_describe", L("Describe a tool"),
"One command's manual, listed or not: a tool, a Design tab command, a menu item that takes no arguments, or an "
"operation a plugin offers (plugin.<plugin>.<name>). It gives the description; every parameter, at every depth, "
"operation a plugin offers (`plugin.<plugin>.<name>`). It gives the description; every parameter, at every depth, "
"with its type, whether the schema requires it, its default, its allowed values or range, the type or target it "
"goes with, and values_from, the tools that list a value the schema can't; the schema's rules as sentences; the "
"Speed Dial items that run it, with their arguments; its examples; how to call it; and access, its read-only, "
"goes with, and `values_from`, the tools that list a value the schema can't; the schema's rules as sentences; the "
"Speed Dial items that run it, with their arguments; its examples; how to call it; and `access`, its read-only, "
"destructive, idempotent and open-world labels. What a handler requires or supplies beyond the schema is in the "
"description. A part of a schema it can't express is kept raw: complete is false and input_schema is the whole schema.",
"description. A part of a schema it can't express is kept raw: `complete` is false and `input_schema` is the whole schema.",
object_schema({{"tool", prop("string", "A command's name.")}}, {"tool"}),
[](const json& args, ToolContext&) {
return ToolResult::ok(describe_command(NativeCommands::instance(), arg_string(args, "tool")));
@@ -687,7 +689,7 @@ void register_api_tools(CommandCatalog& catalog, const std::string& design_index
NativeCommand call = mutate_tool(
"tool_call", L("Call a tool or plugin operation"),
"Call any command by name with its arguments: a tool, or one the tool list does not show, a menu item that takes no "
"arguments, a Design tab command or an operation a plugin offers (tool_list lists them; tool_describe gives any "
"arguments, a Design tab command or an operation a plugin offers (`tool_list` lists them; `tool_describe` gives any "
"command's manual). It runs and is recorded as that command's own call, with its guards and reply budget.",
object_schema({{"tool", prop("string", "The command to call.")},
{"args", {{"type", "object"}, {"description", "Its arguments."}}}},
+22 -22
View File
@@ -320,29 +320,29 @@ void register_app_tools(CommandCatalog& catalog, [[maybe_unused]] bool cad)
"app_state", L("Get app state"),
"Snapshot of OrcaSlicer. Call it first and whenever you are unsure what the app is doing. The app: version, platform "
"and display backend, whether it is ready, the main window, the displays (each one's work area x, y, width and "
"height, as window_set takes positions, its scale and whether it is primary), the MCP endpoint (mcp), python "
"height, as `window_set` takes positions, its scale and whether it is primary), the MCP endpoint (mcp), python "
"(available: Python runs "
"in this build; scripts_unrestricted: a script's own file, network, process and thread access is not held to "
"in this build; `scripts_unrestricted`: a script's own file, network, process and thread access is not held to "
"OrcaSlicer's folders, which only a person turns on, in Preferences > AI features > Python scripts or for one run "
"with --unrestricted-scripts), design_tab "
"(the Design tab is on, and tool_call runs its commands, tool_list's group Design) and, when they do not run, "
"cad_note, how a person turns the CAD feature on; account (signed_in to the Orca cloud, bambu_signed_in to Bambu "
"Lab's), network_plugin (installed, loaded, version, error: the Bambu network plug-in as the app found it) and "
"config_folder (presets, app configuration and logs). The view outside the Design tab (view: sidebar_collapsed, "
"sidebar_width, legend_collapsed, gcode_window, projection, section and the display switches labels, overhangs, "
"outline, wireframe, gridlines, axes and navigator, under the names view_set takes them). "
"with --unrestricted-scripts), `design_tab` "
"(the Design tab is on, and `tool_call` runs its commands, `tool_list`'s group Design) and, when they do not run, "
"`cad_note`, how a person turns the CAD feature on; account (`signed_in` to the Orca cloud, `bambu_signed_in` to Bambu "
"Lab's), `network_plugin` (installed, loaded, version, error: the Bambu network plug-in as the app found it) and "
"`config_folder` (presets, app configuration and logs). The view outside the Design tab (view: `sidebar_collapsed`, "
"`sidebar_width`, `legend_collapsed`, `gcode_window`, projection, section and the display switches labels, overhangs, "
"outline, wireframe, gridlines, axes and navigator, under the names `view_set` takes them). "
"The project: current tab and mode, printer technology, name, path and unsaved changes, "
"selected printer/process/filament presets, plates (count, current), object count, the selection (objects, the "
"instances [[object, instance]] they are selected in and, when parts rather than whole instances are selected, "
"parts [[object, part]], in the indices object_select takes; wipe_tower when a prime tower is selected; canvas is the 3D "
"instances `[[object, instance]]` they are selected in and, when parts rather than whole instances are selected, "
"parts `[[object, part]]`, in the indices `object_select` takes; `wipe_tower` when a prime tower is selected; canvas is the 3D "
"view it belongs to), slicing state, "
"the Preview's view type, time mode and layer range (1-based, with their Z), and the camera of the 3D view shown "
"(camera: type, look_at, position, zoom, click_px_per_mm, elevation and azimuth, as view_set replies with it). What "
"(camera: type, `look_at`, position, zoom, `click_px_per_mm`, elevation and azimuth, as `view_set` replies with it). What "
"is going on: open modal "
"dialogs, each with its title, buttons (enabled: false when disabled) and a message that reads it as shown: its "
"text and its controls row by row, fields [value], choices [value ▾], checkboxes [x] / [ ] / [-], radio and "
"dialogs, each with its title, buttons (`enabled: false` when disabled) and a message that reads it as shown: its "
"text and its controls row by row, fields `[value]`, choices [value ▾], checkboxes `[x]` / [ ] / [-], radio and "
"selector options (*) / ( ), list rows \"- row | cells\", secrets [******], \" (disabled)\" after a disabled "
"control; menus closed unseen (a menu a call opened that no reply listed), dialog_auto_answer rules in force, "
"control; menus closed unseen (a menu a call opened that no reply listed), `dialog_auto_answer` rules in force, "
"notifications, print host uploads (state, progress, error), the open gizmo, running jobs and a running "
"recording.",
object_schema({}), [](const json&, ToolContext& ctx) {
@@ -352,11 +352,11 @@ void register_app_tools(CommandCatalog& catalog, [[maybe_unused]] bool cad)
NativeCommand wait = inspect_tool(
"app_wait", L("Wait for a condition"),
"Block until a condition holds or timeout_s passes (max 50). for: \"ready\" (startup finished), \"idle\" (no dialog, "
"no running job, nothing slicing or arranging, no gizmo working in the background; a script_run run counts only "
"Block until a condition holds or `timeout_s` passes (max 50). `for: \"ready\"` (startup finished), \"idle\" (no dialog, "
"no running job, nothing slicing or arranging, no gizmo working in the background; a `script_run` run counts only "
"through the calls it makes), \"dialog\" / \"no_dialog\", or \"job\" with a job id an earlier call returned, whose "
"result is then the reply. On timeout the reply is {satisfied: false}, or for a job {status: \"running\", job, "
"note}: call it again.",
"result is then the reply. On timeout the reply is `{satisfied: false}`, or for a job `{status: \"running\", job, "
"note}`: call it again.",
object_schema({{"for", enum_prop({"ready", "idle", "dialog", "no_dialog", "job"}, "What to wait for; default job when job "
"is given, else idle.")},
{"job", prop("string", "Job id, for \"job\".")},
@@ -392,7 +392,7 @@ void register_app_tools(CommandCatalog& catalog, [[maybe_unused]] bool cad)
catalog.add(inspect_tool(
"app_log", L("Read the log"),
"The last lines of OrcaSlicer's current log file, optionally only those at or above a level. An entry's level is "
"the one its first line starts with ([error]); the lines of its message after the first come with it, and the "
"the one its first line starts with (`[error]`); the lines of its message after the first come with it, and the "
"reply holds whole entries.",
object_schema({{"lines", {{"type", "integer"}, {"minimum", 1}, {"maximum", 2000},
{"description", "The most lines, of the newest whole entries; an entry longer than that gives its "
@@ -436,7 +436,7 @@ void register_app_tools(CommandCatalog& catalog, [[maybe_unused]] bool cad)
"Take back the last change of a history, as Edit > Undo does. history design is the Design tab's: the last feature "
"added, edited, deleted, moved, shown or hidden, or renamed, or variable changed, or in a sketch session the last "
"drawn shape; project is the project's. Without history, the Design tab's while it is shown, else the project's. "
"Reply: history and, for the Design tab's, result: scope (design or sketch), undo_depth, redo_depth, features, "
"Reply: history and, for the Design tab's, result: scope (design or sketch), `undo_depth`, `redo_depth`, features, "
"bodies and generation; entities in a sketch.",
false);
NativeCommand redo = history_command("redo", L("Redo"), "menu_redo",
@@ -476,7 +476,7 @@ void register_app_tools(CommandCatalog& catalog, [[maybe_unused]] bool cad)
NativeCommand web_page = menu_command(
"app_open_web_page", L("Open a web page"),
"Open one of OrcaSlicer's web pages in the default web browser, as its menu item does: wiki, the OrcaSlicer wiki; "
"youtube, the OrcaSlicer YouTube channel; plugin_hub, the plugin hub's page, where a person picks a plugin to install. "
"youtube, the OrcaSlicer YouTube channel; `plugin_hub`, the plugin hub's page, where a person picks a plugin to install. "
"Nothing opens in OrcaSlicer.",
object_schema({{"page", enum_prop({"wiki", "youtube", "plugin_hub"}, "The page.")}}, {"page"}),
json::array({action("open_wiki", L("Open Wiki"), L("Help"), "link_wiki_img", {{"page", "wiki"}},
+4 -4
View File
@@ -4497,15 +4497,15 @@ std::vector<int> sketch_target_indices(const json& params, const std::vector<int
std::string design_command_index()
{
std::string index = " The Design tab's CAD commands follow by heading (sketches, solid and surface features, bodies, "
"measurements); tool_list {group: \"Design\"} lists them with what each does, and tool_describe {tool} gives "
"measurements); `tool_list {group: \"Design\"}` lists them with what each does, and `tool_describe {tool}` gives "
"one's manual before it is called. A "
"command whose schema has silent does what "
"its menu item does when called with no arguments, unless silent is true.";
"command whose schema has `silent` does what "
"its menu item does when called with no arguments, unless `silent` is true.";
for (const char* section : kDesignSections) {
std::string names;
for (const DesignTool& t : kDesignTools)
if (t.section != nullptr && std::strcmp(t.section, section) == 0)
names += (names.empty() ? "" : ", ") + std::string(t.id);
names += (names.empty() ? "" : ", ") + std::string("`") + t.id + "`";
index += std::string(" ") + section;
if (std::strcmp(section, "Menu items") == 0)
index += ", which take no arguments and do what their item of the right-click menu does";
+1 -1
View File
@@ -307,7 +307,7 @@ json expected_id_prop(const char* of)
{
return {{"type", "integer"},
{"minimum", 0},
{"description", std::string("Optional guard: the ") + of + "'s id in object_list."}};
{"description", std::string("Optional guard: the ") + of + "'s id in `object_list`."}};
}
NativeCommand with_expected_ids(NativeCommand command)
+149 -148
View File
@@ -2867,29 +2867,29 @@ void register_config_tools(CommandCatalog& catalog)
const json type_prop = enum_prop({"printer", "process", "filament"}, "Which settings: the printer, process or filament "
"preset being edited.");
const json target_prop = enum_prop({"global", "object", "part", "height_range"},
"Where they apply: global (default), the type's preset; object, part or height_range, "
"Where they apply: global (default), the type's preset; object, part or `height_range`, "
"the overrides an object, one of its parts or modifiers, or one of its height ranges "
"carries, which are process settings.");
const json object_prop = {{"type", "integer"},
{"minimum", 0},
{"description", "Object index from object_list (targets object, part and height_range); without it, "
{"description", "Object index from `object_list` (targets object, part and `height_range`); without it, "
"the object selected in Prepare."}};
const json part_prop = {{"type", "integer"},
{"minimum", 0},
{"description", "Part index in the object (target part, with object); without both, the part selected "
"in Prepare."}};
const json min_z_prop = {{"type", "number"}, {"minimum", 0}, {"description", "Target height_range: the range's bottom, mm."}};
const json max_z_prop = {{"type", "number"}, {"minimum", 0}, {"description", "Target height_range: the range's top, mm."}};
const json read_preset_prop = prop("string", "Read this saved preset of the type (a name from preset_list) instead of the one "
const json min_z_prop = {{"type", "number"}, {"minimum", 0}, {"description", "Target `height_range`: the range's bottom, mm."}};
const json max_z_prop = {{"type", "number"}, {"minimum", 0}, {"description", "Target `height_range`: the range's top, mm."}};
const json read_preset_prop = prop("string", "Read this saved preset of the type (a name from `preset_list`) instead of the one "
"being edited.");
catalog.add(inspect_tool(
"preset_list", L("List presets"),
"Printer, process or filament presets, each with its name, alias (the name its selector shows, when another), "
"system, user, project (kept inside the project), inherits, selected (and modified), compatible: false or "
"installed: false when so, and vendor; a filament its filament_type and the slots using it (filament_slots), a "
"printer its printer_model and nozzle. Only compatible, installed presets unless asked: a fresh install leaves most "
"system filaments and printers out of the selectors, and preset_select takes such a preset too. printer lists the "
"system, user, project (kept inside the project), inherits, selected (and modified), `compatible: false` or "
"`installed: false` when so, and vendor; a filament its `filament_type` and the slots using it (`filament_slots`), a "
"printer its `printer_model` and nozzle. Only compatible, installed presets unless asked: a fresh install leaves most "
"system filaments and printers out of the selectors, and `preset_select` takes such a preset too. printer lists the "
"filaments or processes that fit another printer preset, in place of the selected one.",
object_schema({{"type", enum_prop({"printer", "process", "filament"}, "Preset category.")},
{"query", prop("string", "Case-insensitive part of the name or alias.")},
@@ -2897,7 +2897,7 @@ void register_config_tools(CommandCatalog& catalog)
"printer's or process's vendor bundle (\"BBL\").")},
{"filament_type", prop("string", "Type filament: a filament type, in either case (\"PLA\").")},
{"printer", prop("string", "Types filament and process: list what fits this printer preset (a name from "
"preset_list type printer) in place of the selected printer.")},
"`preset_list` type printer) in place of the selected printer.")},
{"source", enum_prop({"system", "user", "project"}, "Where the presets come from: the system's, a "
"person's own, or kept inside the project.")},
{"include_incompatible", prop("boolean", "Also list presets incompatible with the printer.")},
@@ -2918,15 +2918,15 @@ void register_config_tools(CommandCatalog& catalog)
catalog.add(reaching({"resolve_preset", "select_preset", "assign_filament_preset"}, mutate_tool(
"preset_select", L("Select a preset"),
"Select a printer, process or filament preset by the name its selector shows (or its internal name), as a person "
"would. One the selectors do not offer (preset_list include_uninstalled) is shown in them first, until the app "
"would. One the selectors do not offer (`preset_list` `include_uninstalled`) is shown in them first, until the app "
"restarts; one the selector leaves out as incompatible with the printer is refused. With unsaved changes the Transfer-or-discard prompt opens "
"(blocked_by_dialog) unless preset_changes answers it. A filament is assigned to filament_slot (1-based, default "
"(`blocked_by_dialog`) unless `preset_changes` answers it. A filament is assigned to `filament_slot` (1-based, default "
"1); with several slots the filament tab keeps the preset and the changes it has, so nothing is asked. Reply: "
"selected, shown (a preset it showed in the selectors); "
"when presets had or have unsaved changes, discarded and modified list per preset the keys dropped and the keys "
"still unsaved.",
object_schema({{"type", enum_prop({"printer", "process", "filament"}, "Preset category.")},
{"name", prop("string", "Preset name as preset_list shows it.")},
{"name", prop("string", "Preset name as `preset_list` shows it.")},
{"filament_slot", {{"type", "integer"}, {"minimum", 1}, {"description", "Filament slot, 1-based."}}},
{"preset_changes", enum_prop({"transfer", "discard"}, "Unsaved changes of the presets the switch replaces: move "
"them to the new preset or drop them, as the prompt's "
@@ -2980,12 +2980,12 @@ void register_config_tools(CommandCatalog& catalog)
NativeCommand save = mutate_tool(
"preset_save", L("Save a preset"),
"Save the printer, process or filament preset being edited, with its unsaved changes, as a preset called name, "
"which is then selected: what the tab's Save button does through its dialog. A filament is filament_slot's "
"which is then selected: what the tab's Save button does through its dialog. A filament is `filament_slot`'s "
"(default 1), and every slot using the old preset takes the new one. Replacing another existing preset needs "
"overwrite (pass it in replays and scripts meant to be rerun). Reply: saved, selected, user, project, inherits, "
"filament_slots. A "
"temperature warning or an unsaved-changes prompt makes it blocked_by_dialog. To keep only some edits, settings_set "
"{reset_all: true, values} first.",
"`filament_slots`. A "
"temperature warning or an unsaved-changes prompt makes it `blocked_by_dialog`. To keep only some edits, `settings_set "
"{reset_all: true, values}` first.",
object_schema({{"type", enum_prop({"printer", "process", "filament"}, "Preset category.")},
{"name", prop("string", "Name to save under.")},
{"filament_slot", {{"type", "integer"}, {"minimum", 1}, {"description", "Filament slot, 1-based."}}},
@@ -3047,10 +3047,10 @@ void register_config_tools(CommandCatalog& catalog)
"and the selection restored; a printer must be selected first, and the physical printers that use only it are "
"deleted with it. Refused: system, default and bundle presets, presets others inherit from, another preset while "
"the edited one of its type has unsaved changes. Deleting a selected printer or process can "
"ask about other presets' unsaved changes (blocked_by_dialog). Reply: deleted, selected, filaments (per slot), "
"attached, and discarded/modified as preset_select's.",
"ask about other presets' unsaved changes (`blocked_by_dialog`). Reply: deleted, selected, filaments (per slot), "
"attached, and discarded/modified as `preset_select`'s.",
object_schema({{"type", enum_prop({"printer", "process", "filament"}, "Preset category.")},
{"name", prop("string", "Preset name as preset_list shows it.")},
{"name", prop("string", "Preset name as `preset_list` shows it.")},
{"delete_attached", prop("boolean", "A custom printer with process or filament presets made for it alone is "
"refused without this: they are deleted with it, as the GUI "
"deletes them.")}},
@@ -3118,19 +3118,20 @@ void register_config_tools(CommandCatalog& catalog)
catalog.add(inspect_tool(
"settings_list", L("List settings"),
"All the settings of a type in one reply, each item with its value as OrcaSlicer writes it, and without meta unless "
"include_meta. process, printer and filament: the preset being edited, or with preset a saved one, or with "
"filament_slot a slot's. object: the process settings an object or an assembly takes; region: those a part, a "
"modifier or a height range takes, whose layer_height item has targets [\"height_range\"], a height range alone "
"All the settings of a type in one reply, each item with its `value` as OrcaSlicer writes it, and without `meta` unless "
"`include_meta`. `process`, `printer` and `filament`: the preset being edited, or with `preset` a saved one, or "
"with `filament_slot` a slot's. `object`: the process settings an object or an assembly takes; `region`: those a "
"part, a "
"modifier or a height range takes, whose `layer_height` item has targets [\"height_range\"], a height range alone "
"taking it; in both, each with the process preset's value, which an object or a region prints with unless it "
"sets its own. With where, the settings of one settings page or \"Page > Group\", as settings_list_pages lists them "
"(an unknown one is refused with the list of them). Items with meta, which where gives them, come 100 a page. "
"settings_get reads settings by key, and what an object, a part or a height range overrides.",
"sets its own. With `where`, the settings of one settings page or \"Page > Group\", as `settings_list_pages` lists them "
"(an unknown one is refused with the list of them). Items with `meta`, which `where` gives them, come 100 a page. "
"`settings_get` reads settings by key, and what an object, a part or a height range overrides.",
object_schema({{"type", enum_prop({"process", "printer", "filament", "object", "region"},
"Which settings: a preset's, or those an object or a region takes.")},
{"where", prop("string", "A settings page, or \"Page > Group\" as meta.where gives it, e.g. "
{"where", prop("string", "A settings page, or \"Page > Group\" as `meta.where` gives it, e.g. "
"\"Strength > Walls\".")},
{"preset", prop("string", "Read this saved preset (a name from preset_list) instead of the one being "
{"preset", prop("string", "Read this saved preset (a name from `preset_list`) instead of the one being "
"edited: of the type, or for object and region a process preset.")},
{"filament_slot", {{"type", "integer"}, {"minimum", 1},
{"description", "Type filament: the slot whose preset is read, 1-based (default 1), with "
@@ -3150,12 +3151,12 @@ void register_config_tools(CommandCatalog& catalog)
catalog.add(inspect_tool(
"settings_list_pages", L("List settings pages"),
"The pages of a type's settings tab and the groups on each, pages and groups in alphabetical order, each group with "
"how many of the settings settings_list lists for the same type it holds: settings_list {type, where} lists that "
"many there. A page and a \"Page > Group\" are each a where settings_list takes, which lists those settings with "
"their values and what each does. A setting with no row on a page is in no group; settings_list without where "
"how many of the settings `settings_list` lists for the same type it holds: `settings_list {type, where}` lists that "
"many there. A page and a \"Page > Group\" are each a `where` `settings_list` takes, which lists those settings with "
"their values and what each does. A setting with no row on a page is in no group; `settings_list` without `where` "
"lists it.",
object_schema({{"type", enum_prop({"process", "printer", "filament", "object", "region"},
"Which settings, as settings_list takes them: a preset's, or those an object or a "
"Which settings, as `settings_list` takes them: a preset's, or those an object or a "
"region takes.")}},
{"type"}),
[](const json& args, ToolContext& ctx) {
@@ -3167,34 +3168,34 @@ void register_config_tools(CommandCatalog& catalog)
catalog.add(inspect_tool(
"settings_get", L("Read settings"),
"Read the settings named: each item has its value, as OrcaSlicer writes it, and meta: label, "
"description (what the setting does, when to change it), where (its settings page and group), type, unit, range, "
"allowed values and mode. Keys the settings lack are listed in unknown_keys, type_of gives where each of those is a "
"setting elsewhere (a type, or project for the project's own settings), and similar the keys like each of the others. "
"It needs keys, compare or a target other than global; settings_list lists all of a type's settings, a page "
"at a time with where, and settings_list_pages the pages.\n"
"- No type: keys look through the process, filament and printer settings, and each item names its "
"type, the one settings_set takes; otherwise the type is the process.\n"
"- type printer, process or filament (target global): the preset being edited, or with preset a saved one; "
"compare lists only the keys that differ from another preset (value and other). A per-variant value lists in meta "
"its variants (what each entry is for) and active (the entry each extruder prints with).\n"
"- target object (object), part (object and part) or height_range (object, min_z and max_z), the object or part "
"selected in Prepare where none is named: without keys, what it overrides; keys read the process "
"settings it takes (settings_list type object or region lists them) and extruder, its filament, and a key it does "
"not take is refused with where it is set. Each has value (its own, null where it has none), effective (the "
"value it prints with) and source, in the order the slicer applies them: height_range, part, object, global or "
"default; an object's item lists in parts the parts and modifiers that override the key inside their own volume, "
"and an object's or a part's item lists in height_ranges the ranges whose value applies to it between their "
"Read the settings named: each item has its `value`, as OrcaSlicer writes it, and `meta`: `label`, "
"`description` (what the setting does, when to change it), `where` (its settings page and group), `type`, `unit`, "
"range, allowed values and `mode`. Keys the settings lack are listed in `unknown_keys`, `type_of` gives where each of those is a "
"setting elsewhere (a type, or project for the project's own settings), and `similar` the keys like each of the others. "
"It needs `keys`, `compare` or a `target` other than global; `settings_list` lists all of a type's settings, a page "
"at a time with `where`, and `settings_list_pages` the pages.\n"
"- No `type`: `keys` look through the process, filament and printer settings, and each item names its "
"type, the one `settings_set` takes; otherwise the type is the process.\n"
"- `type` printer, process or filament (`target` global): the preset being edited, or with `preset` a saved one; "
"`compare` lists only the keys that differ from another preset (`value` and `other`). A per-variant value lists in "
"`meta` its `variants` (what each entry is for) and `active` (the entry each extruder prints with).\n"
"- `target` object (`object`), part (`object` and `part`) or `height_range` (`object`, `min_z` and `max_z`), the "
"object or part selected in Prepare where none is named: without `keys`, what it overrides; `keys` read the process "
"settings it takes (`settings_list` type object or region lists them) and extruder, its filament, and a key it does "
"not take is refused with where it is set. Each has `value` (its own, null where it has none), `effective` (the "
"value it prints with) and `source`, in the order the slicer applies them: `height_range`, part, object, global or "
"default; an object's item lists in `parts` the parts and modifiers that override the key inside their own volume, "
"and an object's or a part's item lists in `height_ranges` the ranges whose value applies to it between their "
"heights. Inside a modifier, mesh or painted, that sets none of a key, the value of the part it overlaps applies, "
"which the command does not work out: where a part (or a modifier of either kind before it) sets the key, the "
"modifier's item has effective null, source overlapped_part, object_effective and object_source (the object's "
"value), and in parts those that set it. These settings are process settings. The reply names the target (objects or parts, and "
"height_range).\n"
"preferences_get reads the app's preferences, plate_get_settings a plate's settings and project_get_settings the "
"modifier's item has `effective` null, `source` `overlapped_part`, `object_effective` and `object_source` (the object's "
"value), and in `parts` those that set it. These settings are process settings. The reply names the target (objects or parts, and "
"`height_range`).\n"
"`preferences_get` reads the app's preferences, `plate_get_settings` a plate's settings and `project_get_settings` the "
"project's own.",
object_schema({{"type", type_prop},
{"target", target_prop},
{"keys", array_prop({{"type", "string"}}, "Option keys, e.g. [\"layer_height\", \"wall_loops\"].")},
{"keys", array_prop({{"type", "string"}}, "Option keys, e.g. `[\"layer_height\", \"wall_loops\"]`.")},
{"object", object_prop},
{"part", part_prop},
{"min_z", min_z_prop},
@@ -3221,37 +3222,37 @@ void register_config_tools(CommandCatalog& catalog)
catalog.add(with_expected_ids(mutate_tool(
"settings_set", L("Change settings"),
"Change settings as typing them into their settings tab would: a type's preset (target global, the default), or "
"the overrides an object, a part or a height range carries (targets object, part and height_range, whose settings "
"the overrides an object, a part or a height range carries (targets object, part and `height_range`, whose settings "
"are process settings). Values "
"are strings in OrcaSlicer's format (\"15%\", \"0.2\", \"1,2\") or JSON numbers, booleans and arrays (a point as "
"[x, y]). All are parsed strictly first and applied together, so nothing changes if one is invalid, and a key of "
"another type is refused with that type named. Reply: applied, and changed, every setting the call changed, "
"`[x, y]`). All are parsed strictly first and applied together, so nothing changes if one is invalid, and a key of "
"another type is refused with that type named. Reply: `applied`, and `changed`, every setting the call changed, "
"including those the app adjusted in turn. An object's or part's change is one undo step; a preset's is not in the "
"undo history. Spiral vase and a few others confirm their adjustments in a dialog (blocked_by_dialog).\n"
"- type printer, process (the default) or filament, target global: null takes a key back to its saved value, or "
"with reset_to parent to the parent's; reset_all first discards every unsaved change, as the tab's undo button "
"does (reply: reverted). A per-variant value (settings_get meta.variants) takes one value for the entries in use "
"(meta.active), {index, value} for one entry, or an array of all.\n"
"- type printer: extruders_count, alone, as the Extruders field of the Printer settings sets it; "
"nozzle_volume_type, each extruder's nozzle flow type as its card in the sidebar picks it; a nozzle_diameter that a "
"undo history. Spiral vase and a few others confirm their adjustments in a dialog (`blocked_by_dialog`).\n"
"- `type` printer, process (the default) or filament, `target` global: a null value takes a key back to its saved "
"value, or with `reset_to` parent to the parent's; `reset_all` first discards every unsaved change, as the tab's undo button "
"does (reply: `reverted`). A per-variant value (`settings_get` `meta.variants`) takes one value for the entries in "
"use (`meta.active`), `{index, value}` for one entry, or an array of all.\n"
"- `type` printer: `extruders_count`, alone, as the Extruders field of the Printer settings sets it; "
"`nozzle_volume_type`, each extruder's nozzle flow type as its card in the sidebar picks it; a `nozzle_diameter` that a "
"variant of the printer model has selects that variant's printer preset, as the sidebar's nozzle diameter does, with "
"nozzle_volume_type alone (other keys go in a second call), each flow type checked against what the new preset's "
"`nozzle_volume_type` alone (other keys go in a second call), each flow type checked against what the new preset's "
"nozzle card offers, or gives where it offers none. The switch asks about the printer's unsaved changes "
"(blocked_by_dialog) unless reset_all discards them first; the discard stays if the switch is not made.\n"
"- target object (object), part (object and part) or height_range (object, min_z and max_z), the object or part "
"selected in Prepare where none is named: overrides of the keys its row offers there (settings_list type object or "
"region), and extruder; a key it does not take is refused with where it is set. null removes one; a height range "
"keeps its layer_height, which is checked against the printer's layer heights for the range's filament. extruder, "
"(`blocked_by_dialog`) unless `reset_all` discards them first; the discard stays if the switch is not made.\n"
"- `target` object (`object`), part (`object` and `part`) or `height_range` (`object`, `min_z` and `max_z`), the "
"object or part selected in Prepare where none is named: overrides of the keys its row offers there (`settings_list` type object or "
"region), and `extruder`; a key it does not take is refused with where it is set. null removes one; a height range "
"keeps its `layer_height`, which is checked against the printer's layer heights for the range's filament. `extruder`, "
"in neither list, is the target's filament (1-based; 0 or null for Default, the object's), set as the Change "
"Filament menu does. The reply names the target (objects or parts, and height_range).\n"
"plate_set_settings changes a plate's settings and project_set_settings the project's own. preferences_set changes "
"the app's preferences; those it refuses (preferences_get marks them refused) change in the Preferences dialog, "
"whose controls carry their effects: window_open {\"window\": \"preferences\", \"tab\": \"<tab>\", \"key\": "
"\"<key>\"}, then widget_set_value {\"target\": {\"name\": \"<key>\", \"within\": \"Preferences\"}, \"value\": "
"...}.",
"Filament menu does. The reply names the target (objects or parts, and `height_range`).\n"
"`plate_set_settings` changes a plate's settings and `project_set_settings` the project's own. `preferences_set` changes "
"the app's preferences; those it refuses (`preferences_get` marks them refused) change in the Preferences dialog, "
"whose controls carry their effects: `window_open {\"window\": \"preferences\", \"tab\": \"<tab>\", \"key\": "
"\"<key>\"}`, then `widget_set_value {\"target\": {\"name\": \"<key>\", \"within\": \"Preferences\"}, \"value\": "
"...}`.",
object_schema({{"type", type_prop},
{"target", target_prop},
{"values", {{"type", "object"}, {"description", "{key: value}, or {key: {index, value}} for one entry"}}},
{"values", {{"type", "object"}, {"description", "`{key: value}`, or `{key: {index, value}}` for one entry"}}},
{"reset_all", prop("boolean", "Target global: discard the unsaved changes before applying values.")},
{"reset_to", enum_prop({"saved", "parent"}, "Target global: what a null value takes a key back to: the "
"saved preset (default) or the preset it inherits from.")},
@@ -3264,7 +3265,7 @@ void register_config_tools(CommandCatalog& catalog)
{"filament_slot", {{"type", "integer"}, {"minimum", 1},
{"description", "Type filament: the slot whose preset is changed, 1-based (default 1). "
"The filament tab switches to it, which can ask about the unsaved "
"changes it holds (blocked_by_dialog)."}}}}),
"changes it holds (`blocked_by_dialog`)."}}}}),
[](const json& args, ToolContext& ctx) {
// Refused before the UI is asked for anything: what the arguments alone decide.
if (const std::string err = settings_request_error(args, /*writes=*/true); !err.empty())
@@ -3419,12 +3420,12 @@ void register_config_tools(CommandCatalog& catalog)
catalog.add(inspect_tool(
"plate_get_settings", L("Read a plate's settings"),
"Read a plate's own settings, as the Plate Settings dialog sets them: curr_bed_type, print_sequence, spiral_mode, "
"first_layer_print_sequence and other_layers_print_sequence; and as its filament grouping sets them on a printer "
"with several extruders: filament_map_mode and filament_map (the extruder of each filament, 1-based). Each with "
"Read a plate's own settings, as the Plate Settings dialog sets them: `curr_bed_type`, `print_sequence`, `spiral_mode`, "
"`first_layer_print_sequence` and `other_layers_print_sequence`; and as its filament grouping sets them on a printer "
"with several extruders: `filament_map_mode` and `filament_map` (the extruder of each filament, 1-based). Each with "
"value (the plate's own, null where it follows the global setting or Auto), effective (what the plate prints with) "
"and meta (meta.offered lists the plate types or grouping modes this printer has). All of them, or those named in "
"keys. Reply: plate, items; unknown_keys for the keys a plate does not have, and similar the plate keys like them.",
"keys. Reply: plate, items; `unknown_keys` for the keys a plate does not have, and similar the plate keys like them.",
object_schema({{"plate", plate_prop},
{"keys", array_prop({{"type", "string"}}, "Setting keys, e.g. [\"curr_bed_type\"].")},
{"include_meta", prop("boolean", "Include labels, types and ranges. Default true.")}}),
@@ -3437,11 +3438,11 @@ void register_config_tools(CommandCatalog& catalog)
catalog.add(mutate_tool(
"plate_set_settings", L("Change a plate's settings"),
"Change a plate's own settings, which it selects and writes as the Plate Settings dialog's OK does: curr_bed_type, "
"print_sequence (\"by layer\", \"by object\"), spiral_mode (true asks for confirmation), first_layer_print_sequence "
"(every slot once, e.g. [2, 1]) and other_layers_print_sequence ([{from: layer >= 2, to, order}], to omitted for "
"the last layer); and as the OK of its filament grouping does, with several extruders: filament_map_mode (an "
"offered mode) and, with \"Manual\", filament_map (one extruder per filament, e.g. [1, 2, 2]; on a printer whose "
"Change a plate's own settings, which it selects and writes as the Plate Settings dialog's OK does: `curr_bed_type`, "
"`print_sequence` (\"by layer\", \"by object\"), `spiral_mode` (true asks for confirmation), `first_layer_print_sequence` "
"(every slot once, e.g. `[2, 1]`) and `other_layers_print_sequence` ([`{from: layer >= 2, to, order}`], to omitted for "
"the last layer); and as the OK of its filament grouping does, with several extruders: `filament_map_mode` (an "
"offered mode) and, with \"Manual\", `filament_map` (one extruder per filament, e.g. `[1, 2, 2]`; on a printer whose "
"extruder holds several nozzles, refused as the dialog refuses it where an extruder it uses has no nozzle of the "
"volume type its filaments print with). null returns a value to the global setting or Auto. Values are checked "
"before anything changes, and the call is one undo step. Reply: plate, applied, changed, and effective for the "
@@ -3453,10 +3454,10 @@ void register_config_tools(CommandCatalog& catalog)
catalog.add(inspect_tool(
"project_get_settings", L("Read the project's settings"),
"Read the project's own settings for its plates: the plate type (curr_bed_type), the prime tower position per plate "
"(wipe_tower_x, wipe_tower_y) and, with several extruders, the filament grouping (filament_map_mode, filament_map); "
"all of them, or those named in keys. The filament list's colours, mixed filaments and flushing are filament_list's. "
"Each item has its value and meta; meta.offered lists the choices this printer has, and meta.read_only marks what is "
"Read the project's own settings for its plates: the plate type (`curr_bed_type`), the prime tower position per plate "
"(`wipe_tower_x`, `wipe_tower_y`) and, with several extruders, the filament grouping (`filament_map_mode`, `filament_map`); "
"all of them, or those named in keys. The filament list's colours, mixed filaments and flushing are `filament_list`'s. "
"Each item has its value and meta; meta.offered lists the choices this printer has, and `meta.read_only` marks what is "
"set elsewhere.",
object_schema({{"keys", array_prop({{"type", "string"}}, "Setting keys, e.g. [\"curr_bed_type\"].")},
{"include_meta", prop("boolean", "Include labels, types and ranges. Default true.")}}),
@@ -3469,25 +3470,25 @@ void register_config_tools(CommandCatalog& catalog)
catalog.add(mutate_tool(
"project_set_settings", L("Change the project's settings"),
"Change the project's own settings as their controls write them: curr_bed_type, as the plate type selector, and "
"Change the project's own settings as their controls write them: `curr_bed_type`, as the plate type selector, and "
"wipe_tower_x/y (mm from the plate's origin, one per plate), as a prime tower's drag. The filament list's colours "
"and flushing are set with filament_set_colour and filament_set_flushing. Values are checked before anything "
"and flushing are set with `filament_set_colour` and `filament_set_flushing`. Values are checked before anything "
"changes; a prime tower move is one undo step. Reply: applied, changed, and a note when the app moved a prime tower "
"that did not fit.",
object_schema({{"values", {{"type", "object"}, {"description", "{key: value}, or {key: {index, value}} for one entry"}}}},
object_schema({{"values", {{"type", "object"}, {"description", "`{key: value}`, or `{key: {index, value}}` for one entry"}}}},
{"values"}),
[](const json& args, ToolContext& ctx) { return set_project_settings(args, ctx); }));
catalog.add(inspect_tool(
"plate_list", L("List plates"),
"Plates with name, locked, current, objects (how many are on it; object_list lists them), and the settings they print with: curr_bed_type, "
"print_sequence, spiral_mode, first_layer_print_sequence and other_layers_print_sequence (null: Auto), with several "
"extruders filament_map_mode and filament_map; overrides "
"lists those the plate sets itself (plate_set_settings). Also origin and size, the plate's place on the bed in "
"mm: the [x, y] of its front left corner and its [width, depth], in the bed coordinates object positions are "
"given in, so that origin plus half the size is its middle; sliced (an up-to-date slice), wipe_tower [x, y] "
"and layer_gcode: the plate's pauses, custom G-code, templates and filament changes, each {z, layer, type, "
"filament, color, gcode}; layer is the Preview slider's number, given while the plate's slice is up to date.",
"Plates with name, locked, current, objects (how many are on it; `object_list` lists them), and the settings they print with: `curr_bed_type`, "
"`print_sequence`, `spiral_mode`, `first_layer_print_sequence` and `other_layers_print_sequence` (null: Auto), with several "
"extruders `filament_map_mode` and `filament_map`; overrides "
"lists those the plate sets itself (`plate_set_settings`). Also origin and size, the plate's place on the bed in "
"mm: the `[x, y]` of its front left corner and its `[width, depth]`, in the bed coordinates object positions are "
"given in, so that origin plus half the size is its middle; sliced (an up-to-date slice), `wipe_tower` `[x, y]` "
"and `layer_gcode`: the plate's pauses, custom G-code, templates and filament changes, each `{z, layer, type, "
"filament, color, gcode}`; layer is the Preview slider's number, given while the plate's slice is up to date.",
object_schema({{"limit", {{"type", "integer"}, {"minimum", 1}, {"maximum", 500}, {"description", "Default 100."}}},
{"offset", {{"type", "integer"}, {"minimum", 0}}}}),
[](const json& args, ToolContext& ctx) { return ToolResult::ok(ctx.run_ui([&] { return list_plates(args); })); }));
@@ -3533,7 +3534,7 @@ void register_config_tools(CommandCatalog& catalog)
"placed on it as on that plate, as Duplicate Current Plate does. The new "
"plate comes last, and the current plate stays current. Refused when the project "
"holds as many plates as it can, and while slicing. One undo step. Reply: plate (the "
"plate copied), new_plate (the new plate's index), " +
"plate copied), `new_plate` (the new plate's index), " +
plates_after + ".",
object_schema({{"plate", plate_prop}}), json(), plate_duplicate_command),
L("Plate"), "menu_copy")));
@@ -3542,7 +3543,7 @@ void register_config_tools(CommandCatalog& catalog)
"Name a plate (plate, else the current one), as its name icon does: a plate other "
"than the current one is made current first. name \"\" leaves it unnamed. With no "
"arguments, as its Speed Dial action, the name dialog asks for the current plate's "
"name (blocked_by_dialog), and a cancelled dialog renames nothing, which the call "
"name (`blocked_by_dialog`), and a cancelled dialog renames nothing, which the call "
"is told. The name is one undo step; the name the plate has already changes "
"nothing, the current plate included. Reply: plate and name.",
object_schema({{"plate", plate_prop},
@@ -3584,7 +3585,7 @@ void register_config_tools(CommandCatalog& catalog)
{"import_presets"},
menu_command("preset_import", L("Import Configs"),
"Import presets from " + preset_file + " by absolute path, without a dialog, " + imported +
" Called with no arguments it is Import Configs: the file dialog asks for the file (blocked_by_dialog).",
" Called with no arguments it is Import Configs: the file dialog asks for the file (`blocked_by_dialog`).",
object_schema({{"path", MenuItems::input_file(preset_file.c_str())},
{"on_conflict", enum_prop({"skip", "overwrite"}, "What happens to a preset that exists already. Default skip.")}},
{"path"}),
@@ -3601,7 +3602,7 @@ void register_config_tools(CommandCatalog& catalog)
"filament), press OK, then answer the result message.";
catalog.add(menu_command(
"preset_export", L("Export Preset Bundle"),
export_dialog + " Every call opens the dialog (blocked_by_dialog). With path, OK writes into that folder instead of "
export_dialog + " Every call opens the dialog (`blocked_by_dialog`). With path, OK writes into that folder instead of "
"asking for one, and a cancelled dialog is an error: nothing was exported.",
object_schema({{"path", prop("string", "Absolute path of an existing folder, which the dialog's OK writes into.")}}),
json::array({action("export_config", L("Export Preset Bundle"), L("Export"), "save", json::object(),
@@ -3662,15 +3663,15 @@ void register_config_tools(CommandCatalog& catalog)
catalog.add(inspect_tool(
"filament_list", L("List the filaments"),
"Read the filament list as the sidebar shows it. filaments has a row per slot in config order, the physical "
"filaments first, then the mixed ones: filament_slot (1-based), mixed, colour (#RRGGBB) and, for a physical "
"filaments first, then the mixed ones: `filament_slot` (1-based), mixed, colour (#RRGGBB) and, for a physical "
"filament, preset and type; for a mixed filament, components (the physical slots it mixes, 1-based, 0 for one "
"deleted), ratios (whole percentages, as filament_add_mixed takes them), gradient (null, or {bottom, top: the "
"components that lead at the bottom and at the top, per_part, curve: linear or custom}) and broken (a component "
"deleted), ratios (whole percentages, as `filament_add_mixed` takes them), gradient (null, or `{bottom, top: the "
"components that lead at the bottom and at the top, per_part, curve: linear or custom}`) and broken (a component "
"deleted or of another filament type: the sidebar marks it, slicing an object on it is refused, and "
"filament_edit_mixed repairs it). Then the flushing the list's Flushing volumes and Purge mode buttons set: "
"flush_multiplier (one per nozzle), flush_volumes_matrix (per nozzle, slots x slots from row to column in config "
"`filament_edit_mixed` repairs it). Then the flushing the list's Flushing volumes and Purge mode buttons set: "
"`flush_multiplier` (one per nozzle), `flush_volumes_matrix` (per nozzle, slots x slots from row to column in config "
"order over every slot, before the multiplier: the dialog shows each entry multiplied by its nozzle's multiplier, "
"and the G-code purges that product) and prime_volume_mode, with prime_volume_modes where the printer offers a "
"and the G-code purges that product) and `prime_volume_mode`, with `prime_volume_modes` where the printer offers a "
"choice. The printer keeps all of it across new projects and restarts; a saved project keeps its own.",
object_schema({}),
[](const json&, ToolContext& ctx) {
@@ -3682,10 +3683,10 @@ void register_config_tools(CommandCatalog& catalog)
catalog.add(reaching({"add_filament_slot"},
own_action(menu_command("filament_add", L("Add Filament Slot"),
"Add a filament slot, as the + button above the filament list does. It takes the next "
"colour and the last slot's preset (change them with filament_set_colour and "
"preset_select filament_slot). It goes after the physical slots: mixed "
"colour and the last slot's preset (change them with `filament_set_colour` and "
"`preset_select` `filament_slot`). It goes after the physical slots: mixed "
"filaments move up by one, and objects on them follow. " +
slot_buttons + " Reply: filament_slot (the new slot) and filament_slots (how many the "
slot_buttons + " Reply: `filament_slot` (the new slot) and `filament_slots` (how many the "
"project has).",
object_schema({}), json(), filament_add_command),
L("Filament"), "add_filament")));
@@ -3693,17 +3694,17 @@ void register_config_tools(CommandCatalog& catalog)
{"delete_filament_slot"},
own_action(menu_command("filament_delete", L("Delete Filament Slot"),
"Delete a filament slot, as its Delete menu item does, the objects on it taking the first filament; "
"with merge_into, as its Merge with item does, the objects on it taking that slot. The slots after "
"it move down by one. A mixed filament (filament_list's mixed rows) is deleted as the mixed "
"with `merge_into`, as its Merge with item does, the objects on it taking that slot. The slots after "
"it move down by one. A mixed filament (`filament_list`'s mixed rows) is deleted as the mixed "
"filament list deletes it, and not merged. A physical filament that a mixed filament mixes is "
"deleted as the sidebar deletes it: the mix is broken (broken_mixed) until filament_edit_mixed "
"deleted as the sidebar deletes it: the mix is broken (`broken_mixed`) until `filament_edit_mixed` "
"names its filaments again. A merge into a mixed filament that mixes the slot asks first, as Merge "
"with does, and replies blocked_by_dialog, unless break_mix answers: true merges, false refuses "
"(mixed_uses_slot). Refused: the only physical slot, and a mixed filament while one physical "
"slot is left, where the sidebar hides the mixed filaments (filament_add first). " +
slot_buttons + " Not in the undo history. Reply: filament_slot (the slot deleted), merged_into "
"(the slot its objects went to, as numbered afterwards), filament_slots, and "
"broken_mixed (the mixed filaments broken afterwards, as numbered then) where "
"with does, and replies `blocked_by_dialog`, unless `break_mix` answers: `true` merges, `false` refuses "
"(`mixed_uses_slot`). Refused: the only physical slot, and a mixed filament while one physical "
"slot is left, where the sidebar hides the mixed filaments (`filament_add` first). " +
slot_buttons + " Not in the undo history. Reply: `filament_slot` (the slot deleted), `merged_into` "
"(the slot its objects went to, as numbered afterwards), `filament_slots`, and "
"`broken_mixed` (the mixed filaments broken afterwards, as numbered then) where "
"there are any.",
object_schema({{"filament_slot", {{"type", "integer"},
{"minimum", 1},
@@ -3714,17 +3715,17 @@ void register_config_tools(CommandCatalog& catalog)
{"description", "The 1-based slot the objects on it go to, as Merge "
"with does. Default: they take the first filament."}}},
{"break_mix", prop("boolean", "The answer to Merge with's question about a merge into "
"a mixed filament that mixes the slot: true merges, "
"false merges nothing. Default: the question opens.")}}),
"a mixed filament that mixes the slot: `true` merges, "
"`false` merges nothing. Default: the question opens.")}}),
json(), filament_delete_command),
L("Filament"), "delete_filament")));
// The Add and Edit Mixed Filament dialogs' controls, for an agent that drives a dialog to set a gradient.
const std::string mixed_dialog =
"replies blocked_by_dialog. Its controls are named filament_1 to filament_3 (the components), gradient, "
"gradient_direction (item 0 puts the first filament at the bottom, item 1 the second) and per_part_gradient, for "
"widget_set_value with within the dialog's title; the gradient shows for a mix of two filaments only, and its curve "
"is drawn, changed only by dragging it (mouse_gesture). Its OK makes what it shows; Cancel changes nothing.";
"replies `blocked_by_dialog`. Its controls are named `filament_1` to `filament_3` (the components), gradient, "
"`gradient_direction` (item 0 puts the first filament at the bottom, item 1 the second) and `per_part_gradient`, for "
"`widget_set_value` with within the dialog's title; the gradient shows for a mix of two filaments only, and its curve "
"is drawn, changed only by dragging it (`mouse_gesture`). Its OK makes what it shows; Cancel changes nothing.";
const auto mix_props = [](const char* components) {
return std::vector<Property>{
{"components", array_prop({{"type", "integer"}, {"minimum", 1}}, components)},
@@ -3748,7 +3749,7 @@ void register_config_tools(CommandCatalog& catalog)
"(1-based), each named once, whose filaments are of one type; ratios a whole percentage for each, adding up to "
"100. It goes after every other slot. A mix the project has already is not added again: the reply names its "
"slot. With neither components nor ratios it opens the Add Mixed Filament dialog, as the sidebar's button does, "
"and " + mixed_dialog + " Not in the undo history. Reply: filament_slot (1-based, where one was added or "
"and " + mixed_dialog + " Not in the undo history. Reply: `filament_slot` (1-based, where one was added or "
"found) and added (false for a mix the project had, or a dialog cancelled).",
object_schema({add_props[0], add_props[1]}),
[mix_args](const json& args, ToolContext& ctx) {
@@ -3774,18 +3775,18 @@ void register_config_tools(CommandCatalog& catalog)
{"tool": "filament_add_mixed", "args": {"components": [1, 2, 3], "ratios": [25, 25, 50]}}]}])json");
catalog.add(std::move(mixed));
const std::vector<Property> edit_props = mix_props("The physical filament slots it mixes from now on, as filament_add_mixed "
const std::vector<Property> edit_props = mix_props("The physical filament slots it mixes from now on, as `filament_add_mixed` "
"takes them. Omitted with ratios: the dialog opens.");
NativeCommand edit_mixed = reaching(
{"edit_mixed_filament"},
mutate_tool(
"filament_edit_mixed", L("Edit Mixed Filament"),
"Change a mixed filament (filament_list's mixed rows) as the Edit Mixed Filament dialog's OK does: components "
"and ratios as filament_add_mixed takes them. The slot keeps its number and the objects on it, and its colour "
"Change a mixed filament (`filament_list`'s mixed rows) as the Edit Mixed Filament dialog's OK does: components "
"and ratios as `filament_add_mixed` takes them. The slot keeps its number and the objects on it, and its colour "
"becomes the blend; a gradient stays for a mix of two filaments and goes for more, as the dialog shows none for "
"them. An edit that names its filaments again repairs a broken mix. With filament_slot alone it opens the Edit "
"them. An edit that names its filaments again repairs a broken mix. With `filament_slot` alone it opens the Edit "
"Mixed Filament dialog on the mix, as a click on its swatch does, and " + mixed_dialog +
" Not in the undo history. Reply: filament_slot and changed.",
" Not in the undo history. Reply: `filament_slot` and changed.",
object_schema({{"filament_slot", {{"type", "integer"}, {"minimum", 1}, {"description", "The mixed filament's 1-based slot."}}},
edit_props[0], edit_props[1]},
{"filament_slot"}),
@@ -3811,8 +3812,8 @@ void register_config_tools(CommandCatalog& catalog)
catalog.add(mutate_tool(
"filament_set_colour", L("Set a filament's colour"),
"Set a physical filament slot's colour, as its colour button's picker does: colour is #RRGGBB. Where Auto flush "
"after changing is on, the flushing volumes are recalculated, so set flush_volumes_matrix (filament_set_flushing) "
"after the colours. A mixed filament's colour is its components' blend and is not set. Reply: filament_slot, "
"after changing is on, the flushing volumes are recalculated, so set `flush_volumes_matrix` (`filament_set_flushing`) "
"after the colours. A mixed filament's colour is its components' blend and is not set. Reply: `filament_slot`, "
"colour (as stored, upper case) and changed.",
object_schema({{"filament_slot", {{"type", "integer"}, {"minimum", 1}, {"description", "The 1-based filament slot."}}},
{"colour", prop("string", "#RRGGBB.")}},
@@ -3822,14 +3823,14 @@ void register_config_tools(CommandCatalog& catalog)
catalog.add(mutate_tool(
"filament_set_flushing", L("Set the flushing"),
"Change the flushing the filament list's Flushing volumes and Purge mode buttons set, as their dialogs' OK does, "
"any of: flush_multiplier (one per nozzle, or one value for all, within the Flushing volumes dialog's range), "
"flush_volumes_matrix (per nozzle, slots x slots from row to column in config order over every slot, before the "
"multiplier; whole, or one entry as {index, value}; a mixed filament's entries, which are never flushed, must be "
"given as they are) and prime_volume_mode (one of filament_list's prime_volume_modes). A colour change "
"(filament_set_colour) can recalculate the matrix, so set it after the colours. Values are checked before "
"any of: `flush_multiplier` (one per nozzle, or one value for all, within the Flushing volumes dialog's range), "
"`flush_volumes_matrix` (per nozzle, slots x slots from row to column in config order over every slot, before the "
"multiplier; whole, or one entry as `{index, value}`; a mixed filament's entries, which are never flushed, must be "
"given as they are) and `prime_volume_mode` (one of `filament_list`'s `prime_volume_modes`). A colour change "
"(`filament_set_colour`) can recalculate the matrix, so set it after the colours. Values are checked before "
"anything changes. Reply: applied and changed.",
object_schema({{"flush_multiplier", {{"type", {"number", "array"}}, {"description", "One value, or one per nozzle."}}},
{"flush_volumes_matrix", {{"type", {"array", "object"}}, {"description", "The whole matrix, or {index, value}."}}},
{"flush_volumes_matrix", {{"type", {"array", "object"}}, {"description", "The whole matrix, or `{index, value}`."}}},
{"prime_volume_mode", prop("string", "The purge mode, e.g. \"Default\".")}}),
[](const json& args, ToolContext& ctx) {
json values = json::object();
@@ -3848,10 +3849,10 @@ void register_config_tools(CommandCatalog& catalog)
ams + " With mode, as the sync dialog's Synchronize now does with that choice, without the dialog: map maps "
"each of the project's filaments to a slot, as the dialog's Mapping first does, which takes a project "
"with objects; overwrite replaces the filament list with the slots' filaments. Called with no arguments, "
"as its Speed Dial action, it opens the sync dialog where the project has objects (blocked_by_dialog), and "
"as its Speed Dial action, it opens the sync dialog where the project has objects (`blocked_by_dialog`), and "
"a warning where it cannot sync. With no printer connected, no AMS or no filament it is refused, saying so. "
"Not in the undo history. Reply: mode, filaments (each slot's preset and colour afterwards) and "
"mapped_to_generic (slots whose filament is unknown, mapped to a generic preset).",
"`mapped_to_generic` (slots whose filament is unknown, mapped to a generic preset).",
object_schema({{"mode", enum_prop({"map", "overwrite"}, "The sync dialog's choice: map or overwrite.")}}),
json::array({action("sync_ams", L("Synchronize Filament List from AMS"), L("Printer"), "ams_fila_sync", json::object(),
ams)}),
+28 -28
View File
@@ -98,9 +98,9 @@ json open_on(const json& args, EType type, const GizmoTargets& reading)
// What every gizmo command's description says of working the open gizmo.
const char* const kWorkTheGizmo =
" Read the gizmo's panel with widget_list {include_imgui: true}, set its fields with widget_set_value, press its "
"buttons with widget_click, and click or drag on the model with mouse_gesture; object_select {none: true} closes it. "
"The gizmo already open on the same target stays open. Reply: gizmo (its name, as app_state.gizmo gives it), active, "
" Read the gizmo's panel with `widget_list {include_imgui: true}`, set its fields with `widget_set_value`, press its "
"buttons with `widget_click`, and click or drag on the model with `mouse_gesture`; `object_select {none: true}` closes it. "
"The gizmo already open on the same target stays open. Reply: gizmo (its name, as `app_state.gizmo` gives it), active, "
"and what is selected (objects, instances, parts).";
// Whether a call of `command` gives one of its acting arguments, and so does the job with no gizmo.
@@ -291,9 +291,9 @@ void register_gizmo_tools(CommandCatalog& catalog)
NativeCommand paint = with_expected_ids(mutate_tool(
"object_paint", L("Paint on an object"),
std::string("Open a painting gizmo on an object's instance, the first unless instance is given: type supports opens "
"Support Painting, seam Seam Painting, color Color Painting (two filaments or more) and fuzzy_skin Paint-on "
"Support Painting, seam Seam Painting, color Color Painting (two filaments or more) and `fuzzy_skin` Paint-on "
"fuzzy skin. Painting is left to the gizmo: pick a tool and a brush in its panel and paint with "
"mouse_gesture strokes on the model. With no target, it opens on the selection as it is.") +
"`mouse_gesture` strokes on the model. With no target, it opens on the selection as it is.") +
kWorkTheGizmo,
with_targets(object_schema({{"type", enum_prop(paint_types, "The painting gizmo to open.")}}, {"type"}), kObjects | kInstances, true),
[](const json& args, ToolContext& ctx) {
@@ -315,7 +315,7 @@ void register_gizmo_tools(CommandCatalog& catalog)
catalog.add(gizmo_command(
"object_measure", L("Measure"),
"Open the Measure gizmo on objects, else on the selection as it is (a part selected is measured as a part). "
"Measuring is left to the gizmo: click two features of the model with mouse_gesture (Shift-click for a point) and "
"Measuring is left to the gizmo: click two features of the model with `mouse_gesture` (Shift-click for a point) and "
"read the results in its panel.",
with_targets(object_schema({}), kObjects, false), EType::Measure, {kObjects, false, nullptr},
json::parse(R"json([
@@ -335,7 +335,7 @@ void register_gizmo_tools(CommandCatalog& catalog)
catalog.add(gizmo_command(
"part_boolean", L("Mesh Boolean"),
"Open the Mesh Boolean gizmo on an object of two parts or more, its first instance. The operation (Union, Difference "
"or Intersection), the two parts and Delete input are left to the gizmo: pick each part with a mouse_gesture click "
"or Intersection), the two parts and Delete input are left to the gizmo: pick each part with a `mouse_gesture` click "
"on a point of it the camera can see, then press the operation's button.",
with_targets(object_schema({}), kObjects, true), EType::MeshBoolean, {kObjects, true, one_instance},
json::parse(R"json([
@@ -343,8 +343,8 @@ void register_gizmo_tools(CommandCatalog& catalog)
{"title": "Open Mesh Boolean on the selected object", "calls": [{"tool": "part_boolean", "args": {}}]}])json")));
const std::vector<std::string> placements{"as_cut", "place_on_cut", "flip"};
json point = array_prop({{"type", "number"}}, "[x, y, z] mm: a point of the plane, in the 3D view's coordinates.");
json normal = array_prop({{"type", "number"}}, "[x, y, z]: the direction the upper piece lies in; any length but zero.");
json point = array_prop({{"type", "number"}}, "`[x, y, z]` mm: a point of the plane, in the 3D view's coordinates.");
json normal = array_prop({{"type", "number"}}, "`[x, y, z]`: the direction the upper piece lies in; any length but zero.");
point["minItems"] = normal["minItems"] = 3;
json plane = object_schema({{"point", std::move(point)}, {"normal", std::move(normal)}}, {"point", "normal"});
plane["description"] = "Cut along this plane. Not with z.";
@@ -352,21 +352,21 @@ void register_gizmo_tools(CommandCatalog& catalog)
"object_cut", L("Cut"),
std::string(
"Cut an object's instance, the first unless instance is given, along a plane, as the Cut gizmo's Perform cut does. "
"Acts from arguments: z, plane, keep, upper, lower, to_parts. With none of them it opens the Cut gizmo. z cuts "
"level, that many mm above the bed; plane {point, normal} cuts along any plane, the upper piece being the one "
"the normal points into. keep: both (default), upper or lower. upper and lower place a kept piece: as_cut, "
"place_on_cut (laid on its cut face) or flip; by default the upper piece is laid on its cut face and the lower "
"one stays as cut. to_parts keeps both pieces as two parts of one object, with no placement. A cut is one undo "
"Acts from arguments: `z`, `plane`, `keep`, `upper`, `lower`, `to_parts`. With none of them it opens the Cut gizmo. z cuts "
"level, that many mm above the bed; plane `{point, normal}` cuts along any plane, the upper piece being the one "
"the normal points into. keep: both (default), upper or lower. upper and lower place a kept piece: `as_cut`, "
"`place_on_cut` (laid on its cut face) or flip; by default the upper piece is laid on its cut face and the lower "
"one stays as cut. `to_parts` keeps both pieces as two parts of one object, with no placement. A cut is one undo "
"step and replaces the object: its pieces go to the end of the object list, upper first, and the reply gives "
"them as pieces [{index, object_id, name, open_edges}], or with to_parts the object and its parts. A piece with "
"open edges is repaired by object_fix. Connectors, the dovetail and a cut along a contour are left to the gizmo: "
"open it with object_cut naming only the object.") +
"them as pieces [`{index, object_id, name, open_edges}`], or with `to_parts` the object and its parts. A piece with "
"open edges is repaired by `object_fix`. Connectors, the dovetail and a cut along a contour are left to the gizmo: "
"open it with `object_cut` naming only the object.") +
kWorkTheGizmo,
with_targets(object_schema({{"z", prop("number", "mm above the bed: cut level at this height. Not with plane.")},
{"plane", std::move(plane)},
{"keep", enum_prop({"both", "upper", "lower"}, "The pieces kept. Default both.")},
{"upper", enum_prop(placements, "Where the upper piece goes. Default place_on_cut.")},
{"lower", enum_prop(placements, "Where the lower piece goes. Default as_cut.")},
{"upper", enum_prop(placements, "Where the upper piece goes. Default `place_on_cut`.")},
{"lower", enum_prop(placements, "Where the lower piece goes. Default `as_cut`.")},
{"to_parts", prop("boolean", "Keep both pieces as two parts of one object, as the gizmo's "
"Cut to parts does. Default false.")}}),
kObjects | kInstances, true),
@@ -387,14 +387,14 @@ void register_gizmo_tools(CommandCatalog& catalog)
"object_lay_on_face", L("Lay on face"),
std::string(
"Lay an object's instance, the first unless instance is given, on one of its faces, as a click on that face in "
"the Lay on Face gizmo does. Acts from arguments: normal, frame. With none of them it opens the Lay on Face "
"the Lay on Face gizmo does. Acts from arguments: `normal`, `frame`. With none of them it opens the Lay on Face "
"gizmo. normal is the direction the face points out to: in the object's own frame (frame object, the default, "
"where [0, 0, -1] is the face that was its bottom) or in the 3D view's (frame world, where the face points now). "
"where `[0, 0, -1]` is the face that was its bottom) or in the 3D view's (frame world, where the face points now). "
"The instance turns so that face lies on the bed and drops onto it, one undo step; the object's other instances "
"turn with it. No flat face is looked for: the direction is laid down as given. A call that acts replies object, "
"instance and rotation, the instance's rotation in degrees as object_list gives it.") +
"instance and rotation, the instance's rotation in degrees as `object_list` gives it.") +
kWorkTheGizmo,
with_targets(object_schema({{"normal", array_prop({{"type", "number"}}, "[x, y, z]: the direction the face to lay on the bed "
with_targets(object_schema({{"normal", array_prop({{"type", "number"}}, "`[x, y, z]`: the direction the face to lay on the bed "
"points out to; any length but zero.")},
{"frame", enum_prop({"object", "world"}, "The frame normal is in: the object's own (default) or "
"the 3D view's. Needs normal.")}}),
@@ -414,20 +414,20 @@ void register_gizmo_tools(CommandCatalog& catalog)
{"tool": "object_lay_on_face", "args": {"object": 0, "normal": [1, 0, 0], "frame": "world"}}]}])json");
catalog.add(reaching({"open_gizmo", "lay_on_face"}, std::move(lay)));
json ear = object_schema({{"position", array_prop({{"type", "number"}}, "[x, y] mm: where on the bed.")},
json ear = object_schema({{"position", array_prop({{"type", "number"}}, "`[x, y]` mm: where on the bed.")},
{"radius", prop("number", "mm. Default: the gizmo's, eight first-layer line widths.")}},
{"position"});
NativeCommand brim = with_expected_ids(mutate_tool(
"object_set_brim_ears", L("Brim ears"),
std::string(
"Set an object's brim ears from positions on the bed, as the Brim Ears gizmo places them, through the instance "
"named, the first unless instance is given. Acts from arguments: points, clear. With none of them it opens the "
"named, the first unless instance is given. Acts from arguments: `points`, `clear`. With none of them it opens the "
"Brim Ears gizmo. points replaces the object's ears with those given, each at a bed position, with a radius "
"from 0.1 to 100 mm or the gizmo's default; clear removes them all. The ears are taken on the bed and stored in "
"the object's coordinates, so they are the object's, shared by its instances. One undo step. They print only "
"with the painted brim type: settings_set on the object sets brim_type. A call that acts replies object, ears "
"as stored ({position: [x, y, z] in the object's coordinates, radius}), brim_type, the brim type the object "
"prints with, and takes_effect, whether that is painted.") +
"with the painted brim type: `settings_set` on the object sets `brim_type`. A call that acts replies object, ears "
"as stored ({position: `[x, y, z]` in the object's coordinates, radius}), `brim_type`, the brim type the object "
"prints with, and `takes_effect`, whether that is painted.") +
kWorkTheGizmo,
with_targets(object_schema({{"points", array_prop(std::move(ear), "The ears, in place of the object's.")},
{"clear", {{"type", "boolean"}, {"enum", {true}}, {"description", "Remove every ear. Not with points."}}}}),
+21 -21
View File
@@ -171,13 +171,13 @@ void register_install_tools(CommandCatalog& catalog)
const json models_prop = {
{"type", "array"},
{"minItems", 1},
{"items", object_schema({{"model", prop("string", "The model, as printer_list_models lists it (\"Bambu Lab X1 Carbon\").")},
{"items", object_schema({{"model", prop("string", "The model, as `printer_list_models` lists it (\"Bambu Lab X1 Carbon\").")},
{"vendor", prop("string", "Its vendor (\"BBL\"), needed where several vendors have a model of that "
"name.")},
{"nozzles", {{"type", "array"},
{"minItems", 1},
{"items", {{"type", "string"}}},
{"description", "Its nozzles, as printer_list_models lists them (\"0.4\"). Default: "
{"description", "Its nozzles, as `printer_list_models` lists them (\"0.4\"). Default: "
"all of them, as the dialog's tick of a model."}}}},
{"model"})},
{"description", "The printer models, each with its nozzles."}};
@@ -186,15 +186,15 @@ void register_install_tools(CommandCatalog& catalog)
"presets selected after it, or drop them, as the Transfer and Discard of the question "
"the dialog's Confirm asks. Needed while presets have unsaved changes; without it the "
"call is refused.");
const std::string reload = "Reloading the presets drops their unsaved changes, so while there are some preset_changes says what "
const std::string reload = "Reloading the presets drops their unsaved changes, so while there are some `preset_changes` says what "
"becomes of them; without it the call is refused. A call that changes nothing reloads nothing. The "
"reload installs a printer's default filaments where no installed filament fits it, as the dialog "
"does, and where a vendor's profile lists default filaments of its own, which none of the shipped "
"profiles does, swaps a @System filament for the vendor's: those are under filaments_installed and "
"filaments_uninstalled. Two errors come after a change and say what it was: vendors_not_installed, "
"profiles does, swaps a @System filament for the vendor's: those are under `filaments_installed` and "
"`filaments_uninstalled`. Two errors come after a change and say what it was: `vendors_not_installed`, "
"where a vendor's profiles cannot be installed (the installed printers are as they were, the "
"unsaved changes discarded if preset_changes said so, and the profiles copied before it stay in "
"the configuration folder), and presets_not_reloaded (the installed printers were written, the "
"unsaved changes discarded if `preset_changes` said so, and the profiles copied before it stay in "
"the configuration folder), and `presets_not_reloaded` (the installed printers were written, the "
"presets not reloaded). Not in the undo history.";
NativeCommand list = NativeCommands::long_command(
@@ -229,11 +229,11 @@ void register_install_tools(CommandCatalog& catalog)
return ToolResult::ok(page(items, args, 100));
});
list.description = "Every printer model OrcaSlicer ships or has installed, of every vendor, as the Printer Selection dialog "
"lists them: each with its vendor (the vendor's id, \"BBL\"), model, nozzles and installed_nozzles, the "
"lists them: each with its vendor (the vendor's id, \"BBL\"), model, nozzles and `installed_nozzles`, the "
"nozzles whose printer presets the printer selector offers. vendor keeps one vendor's models, and query "
"those whose name holds it. The first call after the shipped profiles change reads every vendor, which "
"takes a while and can reply with a job to wait for; later calls read the result kept in the configuration "
"folder. printer_install and printer_uninstall change what is installed.";
"folder. `printer_install` and `printer_uninstall` change what is installed.";
list.listed = true;
list.read_only = true;
list.idempotent = true;
@@ -258,8 +258,8 @@ void register_install_tools(CommandCatalog& catalog)
"names. " +
reload +
" Reply: models (what was named, resolved), added (the printer presets the printer selector offers "
"that it did not before the call), selected, not_offered (named nozzles whose presets it still does "
"not offer), and discarded/modified as preset_select's.",
"that it did not before the call), selected, `not_offered` (named nozzles whose presets it still does "
"not offer), and discarded/modified as `preset_select`'s.",
object_schema({{"models", models_prop}, {"preset_changes", preset_changes_prop}}, {"models"}),
change_printers(true)));
install.examples = json::parse(R"json([
@@ -276,11 +276,11 @@ void register_install_tools(CommandCatalog& catalog)
"Uninstall printer models, for good, as unticking them in the Printer Selection dialog and pressing "
"Confirm does: the printer selector no longer offers their printer presets, and the vendor's profiles stay "
"on disk. Without nozzles a model goes whole. A printer removed while selected is replaced by another "
"installed one. Removing the last installed printer model is refused, and so are names as printer_install "
"installed one. Removing the last installed printer model is refused, and so are names as `printer_install` "
"refuses them. " +
reload +
" Reply: models, removed (the printer presets the printer selector no longer offers), selected, "
"still_offered (named nozzles whose presets it still offers), and discarded/modified as preset_select's.",
"`still_offered` (named nozzles whose presets it still offers), and discarded/modified as `preset_select`'s.",
object_schema({{"models", models_prop}, {"preset_changes", preset_changes_prop}}, {"models"}),
change_printers(false)));
uninstall.examples = json::parse(R"json([
@@ -296,19 +296,19 @@ void register_install_tools(CommandCatalog& catalog)
"printer it fits."}};
const std::string kept = "The app keeps an installed printer's default filaments installed while no other installed filament "
"fits it: where the call leaves one so, they are installed again and listed under "
"filaments_installed, as the next start would. The other filaments, and the presets' unsaved "
"`filaments_installed`, as the next start would. The other filaments, and the presets' unsaved "
"changes, are kept, and the selectors are refreshed. Not in the undo history.";
NativeCommand install_filaments = reaching(
{"install_filaments"},
mutate_tool("filament_install", L("Install system filaments"),
"Install system filaments, for good, as ticking them in the System Filaments dialog and pressing Confirm "
"does: the filament selectors offer them. Name them by names, or with vendor and filament_type every "
"filament of that vendor and type that an installed printer fits. preset_list {type: \"filament\", "
"include_uninstalled: true} lists the system filaments, those not installed with installed: false. A name "
"does: the filament selectors offer them. Name them by names, or with vendor and `filament_type` every "
"filament of that vendor and type that an installed printer fits. `preset_list {type: \"filament\", "
"include_uninstalled: true}` lists the system filaments, those not installed with `installed: false`. A name "
"no filament has is refused with the closest names. " +
kept + " Reply: installed (the presets installed), installed_already, filaments_installed.",
kept + " Reply: installed (the presets installed), `installed_already`, `filaments_installed`.",
object_schema({{"names", names_prop},
{"vendor", prop("string", "With filament_type, in place of names: a filament maker (\"Bambu "
{"vendor", prop("string", "With `filament_type`, in place of names: a filament maker (\"Bambu "
"Lab\", \"Generic\"), in any case.")},
{"filament_type", prop("string", "With vendor: a filament type (\"PLA\"), in any case.")}}),
change_filaments(true)));
@@ -324,9 +324,9 @@ void register_install_tools(CommandCatalog& catalog)
{"uninstall_filaments"},
mutate_tool("filament_uninstall", L("Uninstall system filaments"),
"Uninstall system filaments, for good, as unticking them in the System Filaments dialog and pressing "
"Confirm does: the filament selectors no longer offer them. names as filament_install takes them. A "
"Confirm does: the filament selectors no longer offer them. names as `filament_install` takes them. A "
"filament a slot of the project uses is refused, naming the slot. " +
kept + " Reply: uninstalled (the presets uninstalled), not_installed, filaments_installed.",
kept + " Reply: uninstalled (the presets uninstalled), `not_installed`, `filaments_installed`.",
object_schema({{"names", names_prop}}, {"names"}), change_filaments(false)));
uninstall_filaments.examples = json::parse(R"json([
{"title": "Uninstall a filament", "calls": [
+9 -9
View File
@@ -574,11 +574,11 @@ void register_layer_tools(CommandCatalog& catalog)
catalog.add(with_expected_ids(mutate_tool(
"object_set_height_ranges", L("Set height range modifiers"),
"Replace an object's height range modifiers (Height Range Modifier in the object list): Z ranges in mm, each printed "
"with its own layer_height, filament and process settings, which settings_get and settings_set read and write with "
"the target height_range. A range given with the min_z and max_z of one the object has keeps its settings; a new "
"with its own `layer_height`, filament and process settings, which `settings_get` and `settings_set` read and write with "
"the target `height_range`. A range given with the `min_z` and `max_z` of one the object has keeps its settings; a new "
"one starts from the object's layer height and filament. Ranges may touch but not overlap; [] removes them all. "
"The object is the one named, else the one selected in the Prepare view. One undo step; the object is selected. "
"Reply: the object (objects, object), its height and its ranges as object_list shows them, with their settings, and "
"Reply: the object (objects, object), its height and its ranges as `object_list` shows them, with their settings, and "
"warnings, such as a variable layer height profile deciding the layer heights instead.",
with_targets(object_schema({{"ranges", array_prop(range, "The object's ranges afterwards, in any order.")}}, {"ranges"}), kObjects, true),
[](const json& args, ToolContext& ctx) {
@@ -590,14 +590,14 @@ void register_layer_tools(CommandCatalog& catalog)
catalog.add(with_expected_ids(mutate_tool(
"object_set_variable_layer_height", L("Set a variable layer height profile"),
"Run the Variable layer height panel's Adaptive, Smooth or Reset on an object, without opening the panel: adaptive "
"computes layer heights from the object's shape (inside a height range, the range's layer_height), smooth smooths "
"computes layer heights from the object's shape (inside a height range, the range's `layer_height`), smooth smooths "
"its profile (or the one its height ranges give), reset goes back to its layer height and ranges. The object is "
"the one named, else the one selected in the Prepare view. One undo step; the object is selected. Reply: the "
"object (objects, object), its height, its layer_height_profile {points, min_height, max_height} as object_list "
"object (objects, object), its height, its `layer_height_profile {points, min_height, max_height}` as `object_list` "
"shows it (absent after reset), and warnings.",
with_targets(object_schema({{"action", enum_prop({"adaptive", "smooth", "reset"}, "The panel's button.")},
{"quality", {{"type", "number"}, {"minimum", 0}, {"maximum", 1},
{"description", "adaptive: 0 = quality .. 1 = speed (default 0.5, as the panel)."}}},
{"description", "`adaptive`: 0 = quality .. 1 = speed (default 0.5, as the panel)."}}},
{"radius", {{"type", "integer"}, {"minimum", 1}, {"maximum", 10}, {"description", "smooth: default 5."}}},
{"keep_min", prop("boolean", "smooth: keep the minimum layer heights (default false).")}},
{"action"}),
@@ -635,14 +635,14 @@ void register_layer_tools(CommandCatalog& catalog)
"it and shows the Preview. Applies clear, then remove, then add, all checked first. One code per layer: adding "
"where a code of the same type is replaces it, and where another type is, is refused (remove it first). Not "
"undoable, as in the slider. A change invalidates the "
"plate's slice: slice again before exporting. Reply: the plate's codes as plate_list's layer_gcode lists them, "
"plate's slice: slice again before exporting. Reply: the plate's codes as `plate_list`'s `layer_gcode` lists them, "
"each with z and layer.",
object_schema({{"plate", {{"type", "integer"}, {"minimum", 0}, {"description", "Default: the current plate."}}},
{"add", array_prop(object_schema({{"layer", layer},
{"z", z},
{"type", enum_prop({"pause", "custom", "template", "change_filament"},
"template runs the printer's template_custom_gcode.")},
{"filament", {{"type", "integer"}, {"minimum", 1}, {"description", "change_filament: printed from this layer up."}}},
"template runs the printer's `template_custom_gcode`.")},
{"filament", {{"type", "integer"}, {"minimum", 1}, {"description", "`change_filament`: printed from this layer up."}}},
{"gcode", prop("string", "custom: the G-code.")}},
{"type"}),
"Codes to add, each with layer or z.")},
+9 -9
View File
@@ -271,7 +271,7 @@ ToolFailure plugin_refusal_after(const Ops::Refusal& refusal, const json& before
void register_plugin_tools(CommandCatalog& catalog)
{
using NativeCommands::action;
const json plugin_prop = prop("string", "The plugin's key, as plugin_list gives it, or its name where one plugin has it.");
const json plugin_prop = prop("string", "The plugin's key, as `plugin_list` gives it, or its name where one plugin has it.");
NativeCommand list = inspect_tool(
"plugin_list", L("List plugins"),
@@ -293,8 +293,8 @@ void register_plugin_tools(CommandCatalog& catalog)
NativeCommand local = menu_command(
"plugin_install_local", L("Install Local Plugin"),
"Install a plugin from a .py or .whl file by absolute path, as the Plugins dialog's Install local plugin does, without its "
"file dialog. " + replacing + " Called with no arguments, the file dialog asks for the file (blocked_by_dialog), and "
"replacing an installed plugin asks first (dialog_answer).",
"file dialog. " + replacing + " Called with no arguments, the file dialog asks for the file (`blocked_by_dialog`), and "
"replacing an installed plugin asks first (`dialog_answer`).",
object_schema({{"path", MenuItems::input_file("a .py or .whl plugin package")},
{"overwrite", prop("boolean", "Replace a plugin of that name installed already. Default false.")}},
{"path"}),
@@ -312,9 +312,9 @@ void register_plugin_tools(CommandCatalog& catalog)
"Turn a plugin, or with capability one of its capabilities, on or off, as the Plugins window's switches do. "
"A plugin turned on is loaded, and the call waits for its load to end; a cloud plugin not installed is "
"downloaded and installed first. A plugin that needs a permission while it loads asks in its permission "
"dialog (blocked_by_dialog), which the caller answers. A plugin turned off is unloaded and loses its error. "
"dialog (`blocked_by_dialog`), which the caller answers. A plugin turned off is unloaded and loses its error. "
"A capability is one of a loaded plugin's, by its name; an empty one is refused. Reply: plugin (its row, as "
"plugin_list gives it) and changed; a call that fails once it has changed the plugin, a load that fails "
"`plugin_list` gives it) and changed; a call that fails once it has changed the plugin, a load that fails "
"among them, is an error naming how the plugin is left.",
object_schema({{"plugin", plugin_prop},
{"capability", {{"type", "string"},
@@ -338,9 +338,9 @@ void register_plugin_tools(CommandCatalog& catalog)
{"reload_plugin"},
mutate_tool("plugin_reload", L("Reload a plugin"),
"Load a plugin again after its files changed, as its row's Reload does: it is unloaded and loaded, and a "
"plugin that was not loaded is unloaded again. clear_cache also removes its extracted wheel cache first, as "
"plugin that was not loaded is unloaded again. `clear_cache` also removes its extracted wheel cache first, as "
"Delete cache and reload does. A cloud plugin is installed again from the cloud, as its Reinstall does, and "
"takes no clear_cache; one no longer available is refused. Reply: reloaded, reinstalled and plugin (its row); "
"takes no `clear_cache`; one no longer available is refused. Reply: reloaded, reinstalled and plugin (its row); "
"a reload that fails is an error naming how the plugin is left.",
object_schema({{"plugin", plugin_prop},
{"clear_cache", prop("boolean", "Remove the plugin's extracted wheel cache before loading it. "
@@ -379,8 +379,8 @@ void register_plugin_tools(CommandCatalog& catalog)
refresh_command.description =
"Reload the plugins, as Refresh Plugins does: the installed plugins are rescanned and the plugin hub's list fetched "
"again, and a notification says how it went. The call waits for the refresh to end and replies with the plugins, as "
"plugin_list gives them; a refresh already running, or waiting, runs before the call's own, so the reply comes from a "
"rescan that began after the call. job_cancel stops the wait, not the refresh.";
"`plugin_list` gives them; a refresh already running, or waiting, runs before the call's own, so the reply comes from a "
"rescan that began after the call. `job_cancel` stops the wait, not the refresh.";
refresh_command.listed = true;
refresh_command.cancellable = true;
// It fetches the plugin hub's list.
+19 -19
View File
@@ -165,20 +165,20 @@ void register_preference_tools(CommandCatalog& catalog)
"preferences_get", L("Read preferences"),
"Read the app's preferences as the Preferences dialog shows them. With no argument, every preference it shows, "
"tab by tab in its order, each with key (its control is named after it), tab, section and label (the row's title, "
"in English), kind (checkbox, choice, number or text), value (what the dialog shows: true or false for a checkbox, "
"a number for a number field), a choice's choices ({value, label}; preferences_set takes the value), a number's "
"min and max, stored: false where nothing is stored and the value is the one the dialog shows then, "
"restart_needed: true for a preference read at the next start, which a write changes nothing before, and "
"refused, the reason, for a preference preferences_set does not write. The MCP server's switch and port read as "
"in English), kind (checkbox, choice, number or text), value (what the dialog shows: `true` or `false` for a checkbox, "
"a number for a number field), a choice's choices (`{value, label}`; `preferences_set` takes the value), a number's "
"min and max, `stored: false` where nothing is stored and the value is the one the dialog shows then, "
"`restart_needed: true` for a preference read at the next start, which a write changes nothing before, and "
"refused, the reason, for a preference `preferences_set` does not write. The MCP server's switch and port read as "
"the dialog shows them: on while the server runs, and the port it is on, also where this session's launch "
"arguments set them without storing them; their stored says whether a value is stored. keys and tab narrow "
"the list together; a "
"named key the dialog does not show is read as the app configuration stores it ({key, value}), and one that is "
"neither is listed under unknown_keys. The app configuration also holds account and device state, which is read "
"named key the dialog does not show is read as the app configuration stores it (`{key, value}`), and one that is "
"neither is listed under `unknown_keys`. The app configuration also holds account and device state, which is read "
"only by name.",
object_schema({{"keys", array_prop({{"type", "string"}}, "Preference keys, e.g. [\"project_load_behaviour\"].")},
{"tab", enum_prop({"general", "files", "behaviour", "control", "graphics", "online", "developer"},
"The dialog's tab, as window_open names it.")}}),
"The dialog's tab, as `window_open` names it.")}}),
[](const json& args, ToolContext& ctx) {
return ToolResult::ok(ctx.run_ui([&] {
ui_plater();
@@ -190,23 +190,23 @@ void register_preference_tools(CommandCatalog& catalog)
{"set_preferences"},
mutate_tool(
"preferences_set", L("Change preferences"),
"Change preferences as their controls in the Preferences dialog do: values {key: value}, a checkbox as true or "
"false, a choice as one of its values, a number within its range, as preferences_get lists them, and the "
"downloads folder (download_path) as the absolute path of an existing folder. All are checked first and written "
"Change preferences as their controls in the Preferences dialog do: values `{key: value}`, a checkbox as true or "
"false, a choice as one of its values, a number within its range, as `preferences_get` lists them, and the "
"downloads folder (`download_path`) as the absolute path of an existing folder. All are checked first and written "
"together, so nothing changes if one is refused; then each does what its control does in the app, in the keys' "
"order (the preview redrawn, the sidebar's lists, the settings' mode, the theme, preset sync started or "
"stopped, stealth mode's sign-out of the cloud accounts), and those preferences_get marks restart_needed are "
"stopped, stealth mode's sign-out of the cloud accounts), and those `preferences_get` marks `restart_needed` are "
"stored and take effect at the next start. A key whose value is already the one given is left as it is. "
"Refused, by name and with the reason: a key the dialog does not show, and those preferences_get marks "
"Refused, by name and with the reason: a key the dialog does not show, and those `preferences_get` marks "
"refused, whose control opens a dialog, restarts OrcaSlicer, signs out, or reaches outside it (the language, "
"the login region, the network plug-in, file associations, the mixed-temperature warning, the MCP server's "
"switch and port); those change in the dialog: window_open {\"window\": \"preferences\", \"tab\", "
"\"key\"}, then widget_set_value. Not in the undo history. Reply: changed, [{key, before, after}] typed as "
"preferences_get gives them, with stored_before: false where nothing was stored and before is the value the "
"dialog showed, and restart_needed: true where preferences_get gives it; and unchanged, the keys already so.",
"switch and port); those change in the dialog: `window_open {\"window\": \"preferences\", \"tab\", "
"\"key\"}`, then `widget_set_value`. Not in the undo history. Reply: changed, [`{key, before, after}`] typed as "
"`preferences_get` gives them, with `stored_before: false` where nothing was stored and before is the value the "
"dialog showed, and `restart_needed: true` where `preferences_get` gives it; and unchanged, the keys already so.",
object_schema({{"values", {{"type", "object"},
{"description", "{key: value}, e.g. {\"auto_arrange\": false, \"auto_calculate_flush\": "
"\"color change\"}."}}}},
{"description", "`{key: value}`, e.g. `{\"auto_arrange\": false, \"auto_calculate_flush\": "
"\"color change\"}`."}}}},
{"values"}),
[](const json& args, ToolContext& ctx) {
const json values = args.value("values", json::object());
+19 -19
View File
@@ -37,7 +37,7 @@ NativeCommand job_command(const char* name, const char* title, Ops::JobCommand c
{
NativeCommand job = mutate_tool(
name, title,
description + " The printer's new state arrives when it reports: read it with printer_status. Reply: printer (its "
description + " The printer's new state arrives when it reports: read it with `printer_status`. Reply: printer (its "
"name), state (the state it was in) and sent. A replay sends the command again.",
object_schema({}),
[command](const json&, ToolContext& ctx) {
@@ -116,10 +116,10 @@ void register_printer_tools(CommandCatalog& catalog)
"Print dialog, which leaves the printer, bed levelling, flow calibration, timelapse, the AMS mapping and the button "
"that prints to it; for a printer with a print host (OctoPrint, Moonraker, PrusaLink, Duet...) it is the host's Send "
"G-code to printer host dialog, with Upload and Upload and Print. As the button does, it first applies the slicing "
"result, and it is refused (not_sliced) where the button would be disabled, as for a plate not sliced: slice with "
"plate_slice first. The call replies blocked_by_dialog while the dialog is open: read and set its fields with "
"widget_list and widget_set_value, and press its buttons with dialog_answer. Nothing prints until its button is "
"pressed. Refused: all_plates_not_offered for plates \"all\" where the button offers no Print all, no_print_host for "
"result, and it is refused (`not_sliced`) where the button would be disabled, as for a plate not sliced: slice with "
"`plate_slice` first. The call replies `blocked_by_dialog` while the dialog is open: read and set its fields with "
"`widget_list` and `widget_set_value`, and press its buttons with `dialog_answer`. Nothing prints until its button is "
"pressed. Refused: `all_plates_not_offered` for plates \"all\" where the button offers no Print all, `no_print_host` for "
"a printer with no print host address.",
object_schema({{"plates", plates_prop("Print all")}}), [](const json& args, ToolContext& ctx) {
Ops::OpenPrintDialogArgs op;
@@ -145,12 +145,12 @@ void register_printer_tools(CommandCatalog& catalog)
"Open the dialog the Print button's Send opens for the selected printer, for the current plate or the plate plates "
"names. For a printer on the Bambu network or with printer agents it is the dialog that sends the sliced plate to the "
"printer's storage (with plates \"all\", Send all's), which leaves the printer, the file name, the storage and the "
"button that sends to it, and is refused (not_sliced) for a plate not sliced. For a printer with a print host "
"button that sends to it, and is refused (`not_sliced`) for a plate not sliced. For a printer with a print host "
"(OctoPrint, Moonraker, PrusaLink, Duet...) it is the Send G-code to printer host dialog: set the file name with "
"widget_set_value and press Upload or Upload and Print with dialog_answer; the plate is sliced if needed, then "
"uploaded in the background: app_state.uploads shows the row's state, and a failed upload also opens an error "
"dialog. The call replies blocked_by_dialog while the dialog is open. A replay sends again. Refused: "
"all_plates_not_offered for plates \"all\" where the button offers no Send all, no_print_host for a printer with no "
"`widget_set_value` and press Upload or Upload and Print with `dialog_answer`; the plate is sliced if needed, then "
"uploaded in the background: `app_state.uploads` shows the row's state, and a failed upload also opens an error "
"dialog. The call replies `blocked_by_dialog` while the dialog is open. A replay sends again. Refused: "
"`all_plates_not_offered` for plates \"all\" where the button offers no Send all, `no_print_host` for a printer with no "
"print host address.";
const json send_action = NativeCommands::action("send_gcode", L("Send G-code to printer host"), L("Slice & Export"), "printer",
json::object(), send);
@@ -168,7 +168,7 @@ void register_printer_tools(CommandCatalog& catalog)
"does, with its connection settings as they stand. Reply: ok, whether the host answered, and message, the button's "
"message in the app's language; branch on ok. A cloud host that wants a login is a failed test with the host's "
"message: logging in stays in the printer's connection dialog. The window does not redraw while the host is asked. "
"Refused: no_print_host for a printer with no print host address, host_cannot_be_tested for a kind of host that has "
"Refused: `no_print_host` for a printer with no print host address, `host_cannot_be_tested` for a kind of host that has "
"no test.",
object_schema({}), [](const json&, ToolContext& ctx) {
json reply = ctx.run_ui([] {
@@ -190,10 +190,10 @@ void register_printer_tools(CommandCatalog& catalog)
NativeCommand status = inspect_tool(
"printer_status", L("Printer status"),
"Read what the Device tab shows of the printer it is connected to, without sending it anything. Reply: connected; "
"with a printer, name, model (null where the tab would say Unknown), printer_type (the model's id), online, state "
"(IDLE, PREPARE, RUNNING, PAUSE, FINISH, FAILED...), stage (a number), percent, remaining_seconds, layer, "
"total_layers, file (the job's name), error_code, and temperatures: nozzles (one {current, target} each), bed and "
"chamber, null where the tab shows none. With no printer connected the reply is {\"connected\": false}, which is no "
"with a printer, name, model (null where the tab would say Unknown), `printer_type` (the model's id), online, state "
"(IDLE, PREPARE, RUNNING, PAUSE, FINISH, FAILED...), stage (a number), percent, `remaining_seconds`, layer, "
"`total_layers`, file (the job's name), `error_code`, and temperatures: nozzles (one `{current, target}` each), bed and "
"chamber, null where the tab shows none. With no printer connected the reply is `{\"connected\": false}`, which is no "
"error. The values are what the printer last reported.",
object_schema({}), [](const json&, ToolContext& ctx) {
return ToolResult::ok(ctx.run_ui([] { return printer_status_reply(Ops::printer_status(Ops::connected_printer())); }));
@@ -205,15 +205,15 @@ void register_printer_tools(CommandCatalog& catalog)
catalog.add(job_command(
"print_pause", L("Pause the print"), Ops::JobCommand::Pause,
"Pause the print running on the printer the Device tab is connected to, as the tab's Pause button does. Refused: "
"no_printer_connected with no printer connected, printer_state, naming the state, unless it is RUNNING.",
"`no_printer_connected` with no printer connected, `printer_state`, naming the state, unless it is RUNNING.",
R"json([{"title": "Pause the print once printer_status reads RUNNING", "calls": [
{"tool": "printer_status", "args": {}}, {"tool": "print_pause", "args": {}}]}])json",
false));
catalog.add(job_command(
"print_resume", L("Resume the print"), Ops::JobCommand::Resume,
"Resume the paused print on the printer the Device tab is connected to, as the tab's Resume button does. Refused: "
"no_printer_connected with no printer connected, printer_state, naming the state, unless it is PAUSE, and "
"resume_at_printer, in the app's own sentence, for a job (such as laser processing) that resumes only at the printer.",
"`no_printer_connected` with no printer connected, `printer_state`, naming the state, unless it is PAUSE, and "
"`resume_at_printer`, in the app's own sentence, for a job (such as laser processing) that resumes only at the printer.",
R"json([{"title": "Resume the print once printer_status reads PAUSE", "calls": [
{"tool": "printer_status", "args": {}}, {"tool": "print_resume", "args": {}}]}])json",
false));
@@ -221,7 +221,7 @@ void register_printer_tools(CommandCatalog& catalog)
"print_stop", L("Stop the print"), Ops::JobCommand::Stop,
"Stop the print on the printer the Device tab is connected to, as the tab's Stop button does, but without its "
"question \"Are you sure you want to stop this print?\": it asks nothing, and a stopped print cannot be resumed. "
"Refused: no_printer_connected with no printer connected, printer_state, naming the state, unless it is RUNNING, "
"Refused: `no_printer_connected` with no printer connected, `printer_state`, naming the state, unless it is RUNNING, "
"PAUSE, PREPARE or SLICING.",
R"json([{"title": "Stop the print", "calls": [{"tool": "print_stop", "args": {}}]}])json",
true));
+53 -53
View File
@@ -402,10 +402,10 @@ void register_project_tools(CommandCatalog& catalog)
"project_open", L("Open a project"),
"Open a project (.3mf) by absolute path, without a file dialog, replacing the current project, with the settings it "
"was saved with whatever the Preferences' Load behavior says; when the current project has unsaved changes that "
"fails, changing nothing, unless discard_changes. A G-code file replaces the project too, to show its toolpaths: "
"with unsaved changes the app asks first (blocked_by_dialog), whatever discard_changes says. project_import adds "
"fails, changing nothing, unless `discard_changes`. A G-code file replaces the project too, to show its toolpaths: "
"with unsaved changes the app asks first (`blocked_by_dialog`), whatever `discard_changes` says. `project_import` adds "
"models, or a project's objects alone, to the current project. Called with no arguments it is Load Project: the "
"Open dialog asks for the file (blocked_by_dialog), after asking about the unsaved changes. Reply: opened (project "
"Open dialog asks for the file (`blocked_by_dialog`), after asking about the unsaved changes. Reply: opened (project "
"or gcode), and objects, names and plates for a project, path for a G-code.",
object_schema({{"path", prop("string", "Absolute path of a .3mf project, or of a G-code file (.gcode, .bgcode).")},
{"discard_changes", prop("boolean", "Drop the project's unsaved changes rather than fail when a project "
@@ -450,13 +450,13 @@ void register_project_tools(CommandCatalog& catalog)
NativeCommand import_ = reaching({"import_models"}, mutate_tool(
"project_import", L("Import models"),
"Add the models of files (STL, 3MF, STEP, OBJ, AMF, SVG...) to the current project by absolute path, without a file "
"dialog, as one undo step; a .3mf adds its objects only, not its settings (project_open opens it as a project). A "
"dialog, as one undo step; a .3mf adds its objects only, not its settings (`project_open` opens it as a project). A "
".zip archive gives the model files it holds (STL, OBJ, AMF, 3MF, STEP; a .3mf its objects only, as above), as Import "
"ZIP Archive does: those entries names, by their paths in the archive, else all of them, in place of its file list; "
"an entry the archive lacks is refused with the names it has, before anything is imported. Importing can open a "
"dialog (STEP mesh options, for instance); the reply is then blocked_by_dialog. Called with no arguments it is "
"Import 3MF/STL/STEP/SVG/OBJ/AMF, and with archive: true alone Import ZIP Archive: a file dialog asks for the files, "
"or for the archive and then which of its files to import (blocked_by_dialog). Reply: opened (models), added (how "
"dialog (STEP mesh options, for instance); the reply is then `blocked_by_dialog`. Called with no arguments it is "
"Import 3MF/STL/STEP/SVG/OBJ/AMF, and with `archive: true` alone Import ZIP Archive: a file dialog asks for the files, "
"or for the archive and then which of its files to import (`blocked_by_dialog`). Reply: opened (models), added (how "
"many objects), archives (each archive's path and the entries taken) and the project's objects, names and plates.",
object_schema({{"paths", array_prop({{"type", "string"}}, "Absolute paths of model files, or of a .zip archive of them.")},
{"entries", {{"type", "array"},
@@ -532,14 +532,14 @@ void register_project_tools(CommandCatalog& catalog)
NativeCommand project_new = reaching({"new_project"}, mutate_tool(
"project_new", L("New Project"),
"Start a new, empty project. Called with no arguments, it asks as New Project does, about the unsaved changes "
"if there are any: the reply is then blocked_by_dialog, and dialog_answer answers it. With arguments, or silent: "
"true, it asks nothing: it fails, changing nothing, when the current project has unsaved changes, unless "
"discard_changes. The presets' unsaved changes carry over to the new project unless preset_changes is \"discard\", as "
"if there are any: the reply is then `blocked_by_dialog`, and `dialog_answer` answers it. With arguments, or `silent: "
"true`, it asks nothing: it fails, changing nothing, when the current project has unsaved changes, unless "
"`discard_changes`. The presets' unsaved changes carry over to the new project unless `preset_changes` is \"discard\", as "
"New Project's prompt offers. Reply, with arguments: objects, names, plates; when presets had or have unsaved "
"changes, discarded and modified list per preset the keys dropped and the keys still unsaved. With no arguments "
"the reply is ran and level, also once a prompt is answered, whatever the answer: Cancel keeps the project.",
object_schema({{"discard_changes", prop("boolean", "Drop the project's unsaved changes rather than fail; for the "
"presets', see preset_changes.")},
"presets', see `preset_changes`.")},
{"preset_changes", enum_prop({"keep", "discard"}, "The presets' unsaved changes, not the project's: keep "
"them for the new project (default) or drop them.")}}),
[](const json& args, ToolContext& ctx) {
@@ -574,19 +574,19 @@ void register_project_tools(CommandCatalog& catalog)
NativeCommand calibration = mutate_tool(
"calibration_generate_test", L("Generate a calibration test"),
"Generate a Calibration menu test as its dialog's OK does: a new project named after the test with the test "
"model, and the process, filament and printer presets changed as the test needs (presets_changed). The test prints "
"with filament_slot, a physical filament, on the extruder the filament map gives it, as the dialog's filament list "
"model, and the process, filament and printer presets changed as the test needs (`presets_changed`). The test prints "
"with `filament_slot`, a physical filament, on the extruder the filament map gives it, as the dialog's filament list "
"picks one, so the filament tab is pointed at that slot's preset. Omitted parameters take the dialog's defaults "
"(pressure advance's by the printer's extruder type), except that filament_slot defaults to 1 where the dialog starts "
"(pressure advance's by the printer's extruder type), except that `filament_slot` defaults to 1 where the dialog starts "
"on the filament the filament tab edits; temperatures are clamped to 155-500 °C and rounded "
"down to 5 °C. Fails, changing nothing, when the project has unsaved changes (pass discard_changes) or presets do "
"(pass preset_changes). Called with test alone it opens that test's dialog, as the Calibration menu does "
"(blocked_by_dialog), and the dialog's OK runs the test; silent: true with test alone runs it with the dialog's "
"down to 5 °C. Fails, changing nothing, when the project has unsaved changes (pass `discard_changes`) or presets do "
"(pass `preset_changes`). Called with test alone it opens that test's dialog, as the Calibration menu does "
"(`blocked_by_dialog`), and the dialog's OK runs the test; `silent: true` with test alone runs it with the dialog's "
"defaults. Reply: test, project, params (the values used, which the "
"journal records), objects, names, plates, presets_changed (its filament names the filament_slot, and on a printer "
"with several extruders the extruder, 1-based, where the filament map decides it), result_keys (where the measured value belongs), "
"warnings, adjusted (vfa), and discarded and modified as project_new. Then plate_slice and project_export. To save "
"a measured value: project_new {discard_changes, preset_changes: \"discard\"}, settings_set the value, preset_save.",
"journal records), objects, names, plates, `presets_changed` (its filament names the `filament_slot`, and on a printer "
"with several extruders the extruder, 1-based, where the filament map decides it), `result_keys` (where the measured value belongs), "
"warnings, adjusted (vfa), and discarded and modified as `project_new`. Then `plate_slice` and `project_export`. To save "
"a measured value: `project_new {discard_changes, preset_changes: \"discard\"}`, `settings_set` the value, `preset_save`.",
object_schema(
{{"test", enum_prop({"temperature", "max_volumetric", "pressure_advance", "flow_ratio", "retraction", "vfa", "cornering",
"input_shaping_freq", "input_shaping_damp"},
@@ -596,31 +596,31 @@ void register_project_tools(CommandCatalog& catalog)
{"description", "The physical filament (1-based slot) the test prints with, as the dialog's "
"filament list offers them; a mixed filament is refused. Default 1."}}},
{"method", enum_prop({"tower", "line", "pattern", "pass1", "pass2", "yolo", "yolo_perfectionist"},
"pressure_advance: tower (default), line or pattern; flow_ratio: pass1, pass2, yolo (default) or "
"yolo_perfectionist.")},
{"start", prop("number", "Start of the swept value: °C, mm³/s, PA, mm, mm/s (vfa), Hz (input_shaping_freq), "
"damping (input_shaping_damp), junction deviation mm or jerk mm/s (cornering).")},
"`pressure_advance`: tower (default), line or pattern; `flow_ratio`: pass1, pass2, yolo (default) or "
"`yolo_perfectionist`.")},
{"start", prop("number", "Start of the swept value: °C, mm³/s, PA, mm, mm/s (vfa), Hz (`input_shaping_freq`), "
"damping (`input_shaping_damp`), junction deviation mm or jerk mm/s (cornering).")},
{"end", prop("number", "End of the swept value.")},
{"step", prop("number", "Step: max_volumetric, pressure_advance, retraction, vfa.")},
{"start_y", prop("number", "input_shaping_freq: start of the Y range; default the X one.")},
{"end_y", prop("number", "input_shaping_freq: end of the Y range; default the X one.")},
{"damping", prop("number", "input_shaping_freq: the damping ratio printed with.")},
{"freq_x", prop("number", "input_shaping_damp: the X frequency, Hz.")},
{"freq_y", prop("number", "input_shaping_damp: the Y frequency, Hz; default freq_x.")},
{"shaper_type", prop("string", "Input shaping: an input_shaping_type the printer's firmware offers; default the first.")},
{"step", prop("number", "Step: `max_volumetric`, `pressure_advance`, retraction, vfa.")},
{"start_y", prop("number", "`input_shaping_freq`: start of the Y range; default the X one.")},
{"end_y", prop("number", "`input_shaping_freq`: end of the Y range; default the X one.")},
{"damping", prop("number", "`input_shaping_freq`: the damping ratio printed with.")},
{"freq_x", prop("number", "`input_shaping_damp`: the X frequency, Hz.")},
{"freq_y", prop("number", "`input_shaping_damp`: the Y frequency, Hz; default `freq_x`.")},
{"shaper_type", prop("string", "Input shaping: an `input_shaping_type` the printer's firmware offers; default the first.")},
{"test_model", enum_prop({"ringing_tower", "fast_tower", "scv_v2", "standard", "overhang"},
"Input shaping: ringing_tower (default) or fast_tower; cornering: also scv_v2; temperature on "
"Input shaping: `ringing_tower` (default) or `fast_tower`; cornering: also `scv_v2`; temperature on "
"belt printers: standard (default) or overhang.")},
{"print_numbers", prop("boolean", "pressure_advance line: print the values (default true).")},
{"print_numbers", prop("boolean", "`pressure_advance` line: print the values (default true).")},
{"accelerations", array_prop({{"type", "integer"}, {"minimum", 1}},
"pressure_advance pattern: one test per acceleration and speed; default the process's.")},
{"speeds", array_prop({{"type", "integer"}, {"minimum", 1}}, "pressure_advance pattern: default an optimal speed.")},
{"top_surface_pattern", enum_prop({"archimedeanchords", "monotonic"}, "flow_ratio (default archimedeanchords).")},
"`pressure_advance` pattern: one test per acceleration and speed; default the process's.")},
{"speeds", array_prop({{"type", "integer"}, {"minimum", 1}}, "`pressure_advance` pattern: default an optimal speed.")},
{"top_surface_pattern", enum_prop({"archimedeanchords", "monotonic"}, "`flow_ratio` (default archimedeanchords).")},
{"auto_scale", prop("boolean", "temperature, vfa: scale the model to the nozzle (default true).")},
{"auto_adjust", prop("boolean", "vfa: lower the layer height, else the end speed, to stay within the filament's "
"maximum volumetric speed (default true); only with auto_scale.")},
"maximum volumetric speed (default true); only with `auto_scale`.")},
{"discard_changes", prop("boolean", "Drop the project's unsaved changes rather than fail; for the presets', "
"see preset_changes.")},
"see `preset_changes`.")},
{"preset_changes", enum_prop({"keep", "discard"}, "The presets' unsaved changes, not the project's: keep them for the "
"test or drop them first. Required when presets are modified.")}},
{"test"}),
@@ -790,13 +790,13 @@ void register_project_tools(CommandCatalog& catalog)
NativeCommand save = reaching({"save_project_as"}, mutate_tool(
"project_save", L("Save Project"),
"Save the project. Called with no arguments, it saves as Save Project does: to the project's file (reply: ran, "
"level), or, when it has none, through a file dialog (blocked_by_dialog; a native picker needs dialog_auto_answer "
"registered first); with save_as: true alone, as Save Project As does, always through the file dialog. With path, "
"level), or, when it has none, through a file dialog (`blocked_by_dialog`; a native picker needs `dialog_auto_answer` "
"registered first); with `save_as: true` alone, as Save Project As does, always through the file dialog. With path, "
"it saves a .3mf there without the file dialog, and the file becomes the project's (reply: path, bytes); a name "
"ending in .gcode.3mf is refused (project_export writes that). Either way the save can still open a dialog "
"(blocked_by_dialog): a warning when settings name a plugin OrcaSlicer cannot identify, or an error when the file "
"ending in .gcode.3mf is refused (`project_export` writes that). Either way the save can still open a dialog "
"(`blocked_by_dialog`): a warning when settings name a plugin OrcaSlicer cannot identify, or an error when the file "
"cannot be written. A save that writes nothing, its file dialog or that warning cancelled or the write failed, "
"fails with project_not_saved, and a file already there stays as it was.",
"fails with `project_not_saved`, and a file already there stays as it was.",
object_schema({{"path", prop("string", "Absolute .3mf path.")},
{"overwrite", prop("boolean", "Replace an existing file.")},
{"save_as", prop("boolean", "true, alone: ask for the file in the save dialog, as Save Project As does. With "
@@ -837,7 +837,7 @@ void register_project_tools(CommandCatalog& catalog)
});
// Every call but the two actions' requires path, and a call with path skips the file dialog: silent has nothing to add.
save.input_schema["properties"]["silent"]["description"] =
"Goes with path, which every call but {} and {save_as: true} requires, and adds nothing to it: a call with path skips "
"Goes with path, which every call but {} and `{save_as: true}` requires, and adds nothing to it: a call with path skips "
"the file dialog already.";
catalog.add(save);
@@ -846,23 +846,23 @@ void register_project_tools(CommandCatalog& catalog)
with_expected_ids(mutate_tool(
"project_export", L("Export"),
"Write the project to a file without a dialog. gcode: the plate's G-code (slice first; it is written in the "
"background, and the call returns once it is). sliced_3mf: the sliced plate, or all plates, as .gcode.3mf (slice "
"background, and the call returns once it is). `sliced_3mf`: the sliced plate, or all plates, as .gcode.3mf (slice "
"first: a plate that is not sliced is written without G-code). 3mf: the model without slicing data. stl and drc "
"(Draco): the objects as one file, or with per_object each in a file of its own, named after it, into the folder "
"path names; every object of every plate, or those objects names. toolpaths_obj: the toolpaths the Preview shows, "
"(Draco): the objects as one file, or with `per_object` each in a file of its own, named after it, into the folder "
"path names; every object of every plate, or those objects names. `toolpaths_obj`: the toolpaths the Preview shows, "
"as an OBJ, refused while it shows none (slice the plate and show the Preview first). Without format, the path's "
"extension (.gcode, .gcode.3mf, .3mf, .stl, .drc, .obj) says which. Called with exactly the arguments of one of the "
"File > Export menu items (format alone, sliced_3mf with plates \"all\", stl or drc with per_object), it asks for the file "
"or folder in the dialog that item opens (blocked_by_dialog). A file per object of a project with no objects, and the "
"File > Export menu items (format alone, `sliced_3mf` with plates \"all\", stl or drc with `per_object`), it asks for the file "
"or folder in the dialog that item opens (`blocked_by_dialog`). A file per object of a project with no objects, and the "
"toolpaths while the Preview shows none, are refused in either form. Reply: path and bytes; for gcode, path and "
"export (ok, or superseded with a note when the project changed while it was written); for per_object, path and "
"export (ok, or superseded with a note when the project changed while it was written); for `per_object`, path and "
"files (each file written); for stl and drc, objects (those written).",
with_targets(object_schema({{"format", enum_prop({"gcode", "sliced_3mf", "3mf", "stl", "drc", "toolpaths_obj"},
"What to write; default from the path's extension.")},
{"path", prop("string", "Absolute output path: the file, or with per_object an existing folder.")},
{"path", prop("string", "Absolute output path: the file, or with `per_object` an existing folder.")},
{"plates", {{"type", {"string", "integer"}},
{"description", "\"current\" (default), a plate index, which is selected first and is "
"the plate gcode and sliced_3mf write, or \"all\" (sliced_3mf only)."}}},
"the plate gcode and `sliced_3mf` write, or \"all\" (`sliced_3mf` only)."}}},
{"per_object", prop("boolean", "stl and drc: a file per object, into a folder. Default false.")},
{"overwrite", prop("boolean", "Replace an existing file.")}},
{"path"}),
+19 -18
View File
@@ -371,25 +371,25 @@ void register_python_tools(CommandCatalog& catalog)
{
NativeCommand run = mutate_tool(
"script_run", L("Run a Python script"),
"Run Python code inside OrcaSlicer as its main program (__name__ == \"__main__\") against orca.host, the whole plugin "
"API (script_list_api lists it): read objects, meshes and settings, compute, use orca.host.ui and the preset "
"API, and call these same tools, with their guards and undo, through orca.host.tools.call(name, args). Mesh and "
"Run Python code inside OrcaSlicer as its main program (__name__ == \"__main__\") against `orca.host`, the whole plugin "
"API (`script_list_api` lists it): read objects, meshes and settings, compute, use `orca.host.ui` and the preset "
"API, and call these same tools, with their guards and undo, through `orca.host.tools.call`(name, args). Mesh and "
"matrix arrays need numpy, which "
"script_list_api says is installed or not; a file run's PEP 723 block can install it. The code runs on a worker "
"`script_list_api` says is installed or not; a file run's PEP 723 block can install it. The code runs on a worker "
"thread, where calls documented as UI thread only raise RuntimeError. The run ends once its code and the non-daemon "
"threads and pool tasks it started are done; its windows close with it. `args` holds the args you pass; set `result` "
"to a JSON value to return it; print() output comes back as output. Reply: {status: finished | raised | cancelled | "
"timed_out, result, output, traceback?, message?}; a script that raised changed what it changed before. The code's "
"to a JSON value to return it; print() output comes back as output. Reply: `{status: finished | raised | cancelled | "
"timed_out, result, output, traceback?, message?}`; a script that raised changed what it changed before. The code's "
"own file access is held to OrcaSlicer's folders (its data folder, and read only its resources folder and, for a "
"file run, the file's folder), and it starts no programs or threads and reaches no network: such an access raises "
"PermissionError, unless a person has let Python scripts run unrestricted in Preferences "
"(app_state.python.scripts_unrestricted), when the threads and pool tasks it starts call the tools too while "
"(`app_state.python.scripts_unrestricted`), when the threads and pool tasks it starts call the tools too while "
"the run lasts; the tools it calls work as they do for you. Recorded "
"by replay_export as one step with its code, which a replay runs again against the project as it is then.",
"by `replay_export` as one step with its code, which a replay runs again against the project as it is then.",
object_schema({{"code", prop("string", "Python source, run as a module body.")},
{"args", {{"type", "object"}, {"description", "Bound to the name `args` in the code."}}},
{"timeout_s", {{"type", "integer"}, {"minimum", 1}, {"maximum", 3600},
{"description", "The run is stopped as timed_out after this many seconds (default 300)."}}},
{"description", "The run is stopped as `timed_out` after this many seconds (default 300)."}}},
{"filename", prop("string", "The name tracebacks show for the code (default <script_run>). An existing file's "
"path makes it a file run, as `python file.py` runs it: __file__, sys.argv, imports "
"from its folder and its PEP 723 dependencies; any other name only names it. "
@@ -459,12 +459,13 @@ void register_python_tools(CommandCatalog& catalog)
};
catalog.add(inspect_tool(
"script_list_api", L("List the Python API"),
"List orca, the Python API of script_run scripts and plugins, in the running build, one module or class at a time: "
"orca.host (the project's model and meshes, presets and their editors, slicing data, orca.host.ui windows and "
"dialogs, orca.host.tools calling these tools) and the classes, events and pages plugins build on. It lists what is "
"directly inside within, a module or a class (default orca): each entry's name, kind, signature (a class's "
"constructors) and the first sentence of its documentation. A module or class it lists is listed with within set "
"to its name, and script_describe_api {name} gives an entry's whole documentation. Page with offset. numpy says "
"List `orca`, the Python API of `script_run` scripts and plugins, in the running build, one module or class at a time: "
"`orca.host` (the project's model and meshes, presets and their editors, slicing data, `orca.host.ui` windows and "
"dialogs, `orca.host.tools` calling these tools) and the classes, events and pages plugins build on. It lists what is "
"directly inside `within`, a module or a class (default `orca`): each entry's `name`, `kind`, `signature` (a "
"class's constructors) and the first sentence of its documentation. A module or class it lists is listed with "
"`within` set "
"to its name, and `script_describe_api {name}` gives an entry's whole documentation. Page with `offset`. `numpy` says "
"whether numpy is installed, which mesh and matrix arrays need.",
object_schema({{"within", {{"type", "string"}, {"default", kPythonApiRoot},
{"description", "A module's or class's dotted name, e.g. \"orca.host\" or "
@@ -480,10 +481,10 @@ void register_python_tools(CommandCatalog& catalog)
}));
catalog.add(inspect_tool(
"script_describe_api", L("Describe a Python API entry"),
"Read one entry of orca, the Python API of script_run scripts and plugins, by its dotted name as script_list_api "
"lists it (orca.host.TriangleMesh.face_normals): its kind, its signature (a class's constructors) and its whole "
"Read one entry of `orca`, the Python API of `script_run` scripts and plugins, by its dotted name as `script_list_api` "
"lists it (`orca.host.TriangleMesh.face_normals`): its `kind`, its `signature` (a class's constructors) and its whole "
"documentation. A name no entry has is refused with the closest names.",
object_schema({{"name", prop("string", "An entry's dotted name, as script_list_api lists it.")}}, {"name"}),
object_schema({{"name", prop("string", "An entry's dotted name, as `script_list_api` lists it.")}}, {"name"}),
[while_python_runs](const json& args, ToolContext&) {
return ToolResult::ok(
while_python_runs([&args] { return python_api_entry(python_api_reference(), arg_string(args, "name")); }));
+17 -17
View File
@@ -112,18 +112,18 @@ void register_record_tools(CommandCatalog& catalog)
// The Speed Dial's Start Recording is its action: with no arguments it opens the action's dialog.
NativeCommand start = record_tool(
"recording_start", L("Start Recording"),
"Record a video of OrcaSlicer until recording_stop: the main window with any modal dialog on it (target main), or "
"Record a video of OrcaSlicer until `recording_stop`: the main window with any modal dialog on it (target main), or "
"the 3D view shown (canvas). Frames are MJPEG in a Matroska (.mkv) file with their real timestamps. With captions, "
"the tool call acting on the app shows as a caption at the bottom (secret setting values never show); with pointer, "
"the pointer is highlighted, its clicks rippling. Capture takes at most about a third of the UI thread, so "
"the frame rate drops where capturing is slow. One recording at a time: one a replay or script starts ends with it, a "
"client's when the server is turned off. With encode, the recording_stop that reports it also encodes it to an MP4 "
"client's when the server is turned off. With encode, the `recording_stop` that reports it also encodes it to an MP4 "
"beside it, as Start Recording does, and the .mkv is deleted once the MP4 is written unless "
"keep_raw_video_file; recording_encode makes an MP4 of any recording later. Called with no "
"arguments, it opens the Start Recording dialog instead, as Start Recording does (blocked_by_dialog): "
"its controls are named after their settings for widget_set_value, dialog_answer \"Start recording\" starts the "
"`keep_raw_video_file`; `recording_encode` makes an MP4 of any recording later. Called with no "
"arguments, it opens the Start Recording dialog instead, as Start Recording does (`blocked_by_dialog`): "
"its controls are named after their settings for `widget_set_value`, `dialog_answer` \"Start recording\" starts the "
"person's recording, which neither the end of a replay or script nor the server turning off ends, and the dialog "
"remembers the settings; silent: true starts one here at once with the defaults.",
"remembers the settings; `silent: true` starts one here at once with the defaults.",
object_schema({{"target", enum_prop({"main", "canvas"}, "main (default): the main window and its dialogs; canvas: the 3D view shown.")},
{"fps", int_prop(1, 30, "Frames per second at most (default 10).")},
{"max_dim", int_prop(320, 3840, "Long edge of the video in pixels (default 1920).")},
@@ -143,7 +143,7 @@ void register_record_tools(CommandCatalog& catalog)
{"keep_raw_video_file", prop("boolean", "With encode: keep the .mkv beside the MP4 (default false: the "
"encode deletes it once the MP4 is written).")},
{"save_path", prop("string", "Absolute .mkv path; default the session's output folder.")},
{"overwrite", prop("boolean", "Replace an existing save_path, and with encode its MP4.")}}),
{"overwrite", prop("boolean", "Replace an existing `save_path`, and with encode its MP4.")}}),
[](const json& args, ToolContext& ctx) {
AutomationRuntime& runtime = ctx.runtime();
RecordingOptions o;
@@ -234,18 +234,18 @@ void register_record_tools(CommandCatalog& catalog)
// The Speed Dial's Stop Recording is its action: with no arguments it stops as the action does.
NativeCommand stop = record_tool("recording_stop", L("Stop Recording"),
"Stop the running recording. Call it with silent: true for the report: it waits for the file and "
"Stop the running recording. Call it with `silent: true` for the report: it waits for the file and "
"returns it with its seconds, frames captured and "
"written, frames dropped when encoding fell behind, failed when they could not be encoded, or "
"skipped when the window could not be captured, "
"the size, the mean UI-thread time a capture took (capture_ms), and why it ended. A recording that ended on its own (max_seconds, the replay or script that started it ended, a "
"write error) is reported once by the next recording_stop. For a recording started with encode, it then "
"starts the MP4 encode and returns it under encode: a job, whose app_wait {for: \"job\"} returns "
"recording_encode's result, whose raw_video_file_deleted says whether the .mkv was deleted. "
"the size, the mean UI-thread time a capture took (`capture_ms`), and why it ended. A recording that ended on its own (`max_seconds`, the replay or script that started it ended, a "
"write error) is reported once by the next `recording_stop`. For a recording started with encode, it then "
"starts the MP4 encode and returns it under encode: a job, whose `app_wait {for: \"job\"}` returns "
"`recording_encode`'s result, whose `raw_video_file_deleted` says whether the .mkv was deleted. "
"Called with no arguments, it stops "
"the recording as Stop Recording does, whoever started it: without waiting for its "
"file, it shows the person a notification naming it and replies with its path; the next "
"recording_stop with silent: true reports it as ended stopped_in_app.",
"`recording_stop` with `silent: true` reports it as ended `stopped_in_app`.",
object_schema({}), [](const json&, ToolContext& ctx) {
AutomationRuntime& runtime = ctx.runtime();
// The last state too, even if the timer has not ticked since the last call. Without the
@@ -285,12 +285,12 @@ void register_record_tools(CommandCatalog& catalog)
"recording_encode", L("Encode a recording"),
"Encode a recording into an H.265 (or H.264) MP4 with the system ffmpeg (ORCA_FFMPEG, else ffmpeg on PATH; it "
"needs libx265 or libx264), keeping its timing. Takes this session's last finished recording unless path names "
"one, and writes beside it unless save_path says where. A long encode returns a job: app_wait waits for it, or job_cancel {job} "
"stops it. Once the MP4 is written, it deletes the .mkv if this session recorded it, unless keep_raw_video_file; "
"any other .mkv is kept. raw_video_file_deleted in the reply says which.",
"one, and writes beside it unless `save_path` says where. A long encode returns a job: `app_wait` waits for it, or `job_cancel {job}` "
"stops it. Once the MP4 is written, it deletes the .mkv if this session recorded it, unless `keep_raw_video_file`; "
"any other .mkv is kept. `raw_video_file_deleted` in the reply says which.",
object_schema({{"path", prop("string", "Absolute .mkv of a finished recording; default this session's last.")},
{"save_path", prop("string", "Absolute .mp4 path; default the recording's, with .mp4.")},
{"overwrite", prop("boolean", "Replace an existing save_path.")},
{"overwrite", prop("boolean", "Replace an existing `save_path`.")},
{"codec", enum_prop({"h265", "h264"}, "Default h265.")},
{"crf", int_prop(0, 51, "Constant rate factor, lower is better and larger (default 28 for h265, 23 for h264).")},
{"speed", enum_prop(encoder_speeds(), "The encoder's preset: slower makes a smaller file of the same quality (default medium).")},
+17 -15
View File
@@ -112,18 +112,20 @@ void register_replay_tools(CommandCatalog& catalog)
{
NativeCommand run = mutate_tool(
"replay_run", L("Run a replay"),
std::string("Replay a list of tool calls in order and report each step: {orca_replay_version:\"") + REPLAY_VERSION +
"\", name, vars, steps:[{tool, args, expect, "
"optional, await, save_as, timeout_s}]}, JSON with comments. Strings may use ${replay_dir}, ${out_dir}, ${env:NAME}, "
"${vars.NAME} and ${jobs.NAME}. A step that returns a job is awaited unless await:false, which stores the job under "
"save_as so later steps can answer the dialog it opened. expect maps a JSON pointer into the step's result to "
"matchers (eq ne gt ge lt le contains regex exists empty); the first failed step or expectation stops the run unless "
"the step is optional. Writes result.json to out_dir (default: a new folder replay-<timestamp> in orca_action_replay "
"in the temp folder, or in the --outputdir folder of a --run launch). Reply: passed, steps, failed_step, out_dir and "
"result_file. dialog_auto_answer rules a replay registers end with it. replay_export turns this session into one.",
std::string("Replay a list of tool calls in order and report each step: `{\"orca_replay_version\": \"") +
REPLAY_VERSION +
"\", name, vars, steps: [{tool, args, expect, optional, await, save_as, timeout_s}]}`, JSON with comments. "
"Strings may use `${replay_dir}`, `${out_dir}`, `${env:NAME}`, `${vars.NAME}` and `${jobs.NAME}`. A step that "
"returns a job is awaited unless `await: false`, which stores the job under `save_as` so later steps can answer "
"the dialog it opened. `expect` maps a JSON pointer into the step's result to matchers (`eq` `ne` `gt` `ge` `lt` "
"`le` `contains` `regex` `exists` `empty`); the first failed step or expectation stops the run unless the step is "
"`optional`. Writes `result.json` to `out_dir` (default: a new folder `replay-<timestamp>` in "
"`orca_action_replay` in the temp folder, or in the `--outputdir` folder of a `--run` launch). Reply: `passed`, "
"`steps`, `failed_step`, `out_dir` and `result_file`. `dialog_auto_answer` rules a replay registers end with it. "
"`replay_export` turns this session into one.",
object_schema({{"path", prop("string", "Absolute path of a replay file.")},
{"replay", {{"type", json::array({"object", "string"})},
{"description", "The replay itself, as an object or as its JSON text, instead of path."}}},
{"description", "The replay itself, as an object or as its JSON text, instead of `path`."}}},
{"out_dir", prop("string", "Absolute directory for result.json and screenshots; created if missing.")},
{"vars", {{"type", "object"}, {"description", "Values that override the replay's vars."}}}}),
[](const json& args, ToolContext& ctx) {
@@ -172,12 +174,12 @@ void register_replay_tools(CommandCatalog& catalog)
NativeCommand exp = inspect_tool(
"replay_export", L("Export this session as a replay"),
"Turn the calls this session made into a replay that replay_run runs: mutating calls, app_wait, window_screenshot and the "
"recording tools, in order, with refs replaced by locators, job replies replayed with await:false, and window_screenshot "
"and recording paths moved under ${out_dir}. "
"Calls that failed, at once or as a job later, are left out (a script_run that raised or timed out replied, so it "
"Turn the calls this session made into a replay that `replay_run` runs: mutating calls, `app_wait`, `window_screenshot` and the "
"recording tools, in order, with refs replaced by locators, job replies replayed with await:false, and `window_screenshot` "
"and recording paths moved under `${out_dir}`. "
"Calls that failed, at once or as a job later, are left out (a `script_run` that raised or timed out replied, so it "
"stays); so is a call whose job is still running (unless it "
"waits on a dialog), which left_out_running lists as {tool, job}. "
"waits on a dialog), which `left_out_running` lists as `{tool, job}`. "
"Reply: the replay, which with path is also written there. clear:true then forgets the calls made so far.",
object_schema({{"name", prop("string", "Replay name.")},
{"path", prop("string", "Absolute .json path to write.")},
+97 -96
View File
@@ -1646,8 +1646,8 @@ void register_object_menu_commands(CommandCatalog& catalog)
// ---- Add Primitive and Add Handy models ---- (the Add menu; each creates a new object)
const json shape_size = array_prop({{"type", "number"}}, "mm, the Primitive size dialog's fields, in place of the dialog: cube "
"[x, y, z]; cylinder, cone, disc [diameter, height]; sphere [diameter]; "
"torus [inner diameter, tube diameter]; each above 0.");
"`[x, y, z]`; cylinder, cone, disc `[diameter, height]`; sphere `[diameter]`; "
"torus `[inner diameter, tube diameter]`; each above 0.");
// A shape the plate may then turn toward the part-cooling fan.
const std::string turned = " The shape may then be turned toward the part-cooling fan, so the size is along its own axes before that turn.";
const auto primitive = [&turned](const char* key, const char* title, const char* icon, const char* shape, bool turns) {
@@ -1661,17 +1661,17 @@ void register_object_menu_commands(CommandCatalog& catalog)
NativeCommand add_primitive = menu_command(
"object_add_primitive", L("Add a primitive"),
"Add a primitive shape (cube, cylinder, sphere, cone, disc or torus) as a new object, as Add Primitive does: on the "
"current plate, or on plate, which becomes the current one; at position, in the bed coordinates object_list and "
"object_transform use, else where Add Primitive puts it; named name, else after its shape. With a size, at that "
"current plate, or on plate, which becomes the current one; at position, in the bed coordinates `object_list` and "
"`object_transform` use, else where Add Primitive puts it; named name, else after its shape. With a size, at that "
"size; with silent, at the shape's built-in size. With shape alone, as its Speed Dial actions, the Primitive size "
"dialog asks for the size (blocked_by_dialog), unless a person turned that dialog off, and the call is refused "
"while an object is selected (part_add adds a shape to an object); any other call adds the object whatever is "
"dialog asks for the size (`blocked_by_dialog`), unless a person turned that dialog off, and the call is refused "
"while an object is selected (`part_add` adds a shape to an object); any other call adds the object whatever is "
"selected. One undo step; the new object is selected. Reply: the object (objects, object), its plate and offset." +
turned,
object_schema({{"shape", enum_prop({"cube", "cylinder", "sphere", "cone", "disc", "torus"}, "The shape.")},
{"size", shape_size},
{"plate", {{"type", "integer"}, {"minimum", 0}, {"description", "The plate to add it on. Default: the current plate."}}},
{"position", array_prop({{"type", "number"}}, "[x, y, z] mm: where its first instance goes, as object_transform's "
{"position", array_prop({{"type", "number"}}, "`[x, y, z]` mm: where its first instance goes, as `object_transform`'s "
"position; it then rests on the bed.")},
{"name", prop("string", "The object's name. Default: its shape's.")}},
{"shape"}),
@@ -1704,8 +1704,8 @@ void register_object_menu_commands(CommandCatalog& catalog)
}
catalog.add(menu_command(
"object_add_handy_model", L("Add a handy model"),
"Add one of the test models OrcaSlicer ships to the current plate, as Add Handy models does; orca_cube and "
"orcasliced_combo, of several files, then arrange the objects as the toolbar's Arrange does, which moves the others too. "
"Add one of the test models OrcaSlicer ships to the current plate, as Add Handy models does; `orca_cube` and "
"`orcasliced_combo`, of several files, then arrange the objects as the toolbar's Arrange does, which moves the others too. "
"Reply: the objects added (objects: index, id and name).",
object_schema({{"model", enum_prop(models, "The model.")}}, {"model"}), std::move(handy_actions), [](const json& args) {
const std::string model = arg_string(args, "model");
@@ -1729,16 +1729,17 @@ void register_object_menu_commands(CommandCatalog& catalog)
schema["properties"]["type"] = enum_prop({"part", "negative", "modifier"},
"The part's type, as the object's Add menu offers it. Default part. Without "
"object, on the selected object, or the object of the parts selected, "
"which is selected whole first: refused (nothing_selected, "
"one_object_only) unless one object is selected.");
"which is selected whole first: refused (`nothing_selected`, "
"`one_object_only`) unless one object is selected.");
return with_targets(std::move(schema), kObjects, true);
};
const std::string text = "Add a text: a part on the selected object, or a new object when nothing is selected. It is created "
"in the background (app_wait {for: \"idle\"} waits for it), and the Text gizmo opens on it.";
"in the background (`app_wait {for: \"idle\"}` waits for it), and the Text gizmo opens on it.";
catalog.add(with_expected_ids(menu_command(
"object_add_text", L("Text"),
text + " With object, the text becomes a part of that object, which is selected first; type makes it a negative part "
"or a modifier, as the object's Add menu does.",
"or a modifier, as the object's Add menu does. Reply: only that it ran (`ran`, `level`), since the text is made "
"later: once `app_wait {for: \"idle\"}` returns, `object_list` shows it and `app_state` the gizmo.",
part_props({}),
json::array({action("add_primitive_text", L("Text"), L("Add Primitive"), "menu_obj_text", json::object(), text)}),
[](const json& args) { return MenuItems::add_primitive_text(args); })));
@@ -1746,10 +1747,11 @@ void register_object_menu_commands(CommandCatalog& catalog)
catalog.add(with_expected_ids(menu_command(
"object_add_svg", L("SVG"),
"Add an SVG as a new object, or as a part of the selected object. With a path, uses that file without a dialog; the "
"part is created in the background (app_wait {for: \"idle\"} waits for it), and the SVG gizmo opens on it. With "
"part is created in the background (`app_wait {for: \"idle\"}` waits for it), and the SVG gizmo opens on it. With "
"object, the SVG becomes a part of that object, which is selected first; type makes it a negative part or a modifier, "
"as the object's Add menu does. Without path the file dialog opens, as the action's does, and the object and type "
"apply to the file picked there.",
"apply to the file picked there. Reply: only that it ran (`ran`, `level`), since the part is made later: once "
"`app_wait {for: \"idle\"}` returns, `object_list` shows it and `app_state` the gizmo.",
part_props({{"path", MenuItems::input_file("an .svg file")}}),
json::array({action("add_primitive_svg", L("SVG"), L("Add Primitive"), "menu_obj_svg", json::object(),
"Add an SVG as a new object, or as a part of the selected object, from the file a dialog asks for; "
@@ -1765,10 +1767,10 @@ void register_object_menu_commands(CommandCatalog& catalog)
"with none of these what is selected in the Prepare view. An object whose every instance or every part is named goes "
"whole. An object's last solid part alone, and a cut object or a solid or negative part of one, are refused with "
"the message or the question Delete gives; a call with no arguments leaves them to the object list, which shows "
"the message or asks the question (blocked_by_dialog), and all deletes cut objects without asking, as Delete All "
"the message or asks the question (`blocked_by_dialog`), and all deletes cut objects without asking, as Delete All "
"does. One undo step. Reply: what was deleted (objects, instances, parts, with the indices they had); kept, what "
"was named and stayed, with its indices now (the object list deletes from the last named and stops at what it "
"refuses or asks about); and object_count, the objects left; the objects after a deleted one move down.",
"refuses or asks about); and `object_count`, the objects left; the objects after a deleted one move down.",
with_targets(object_schema({{"plate", {{"type", "integer"}, {"minimum", 0}, {"description", "Delete what stands on this plate."}}},
{"all", prop("boolean", "Delete every object. Default false: the targets.")}}),
kEveryTarget, false),
@@ -1797,7 +1799,7 @@ void register_object_menu_commands(CommandCatalog& catalog)
"object_set_instances", L("Set the number of instances"),
"Give an object this many instances (count), as Set Number of Instances does, or one more or one fewer (delta 1 "
"or -1), as the toolbar's + and - do: the object named, else the one selected in the Prepare view, or the object "
"of the selected instance or part. With no arguments the dialog asks for the count (blocked_by_dialog). New "
"of the selected instance or part. With no arguments the dialog asks for the count (`blocked_by_dialog`). New "
"instances overlap; arrange afterwards. One undo step; the object is selected. Reply: the object (objects, "
"object) and instances, how many it has.",
with_targets(object_schema({{"count", {{"type", "integer"},
@@ -1845,13 +1847,13 @@ void register_object_menu_commands(CommandCatalog& catalog)
"object's own other than a part's, and into parts a part's row, or another row of the object. A mesh of one shell "
"is refused, and into parts so is an object of several parts, whose part is selected to split it. Into objects, "
"the object is removed and its pieces are added last and selected. Where some of them "
"would float above the bed of an object that drops, keep_z answers the question Split asks (true keeps their "
"height, false lets them drop), and without it the call is refused (auto_drop_question); with only an action's "
"arguments Split asks it (blocked_by_dialog). One undo step. Reply: the new objects (objects) or the parts the "
"part became (parts), with their indices afterwards, and object_count.",
"would float above the bed of an object that drops, `keep_z` answers the question Split asks (true keeps their "
"height, false lets them drop), and without it the call is refused (`auto_drop_question`); with only an action's "
"arguments Split asks it (`blocked_by_dialog`). One undo step. Reply: the new objects (objects) or the parts the "
"part became (parts), with their indices afterwards, and `object_count`.",
with_targets(object_schema({{"into", enum_prop({"objects", "parts"}, "Separate objects, or parts of the object.")},
{"keep_z", prop("boolean", "Into objects, the answer to the question whether pieces that would "
"float above the bed keep their height: true keeps it, false "
"float above the bed keep their height: `true` keeps it, `false` "
"lets them drop.")}},
{"into"}),
kObjects, true),
@@ -1910,13 +1912,13 @@ void register_object_menu_commands(CommandCatalog& catalog)
"puts them: order names each of the plate's objects once, by index, and anything else is refused; the "
"other plates' objects keep their order. One undo step, none when the order stays as it was; object indices "
"change. Reply: the new order (order: "
"[{object, name, plate}]), and descending with by.",
"[`{object, name, plate}`]), and descending with by.",
object_schema({{"plate", {{"type", "integer"}, {"minimum", 0}, {"description", "Order this plate's objects. Default: the current plate."}}},
{"by", enum_prop({"name", "filament", "height", "size"}, "What to order by.")},
{"order", {{"type", "array"},
{"minItems", 1},
{"items", {{"type", "integer"}, {"minimum", 0}}},
{"description", "In place of by: the plate's objects, by index (object_list), each "
{"description", "In place of by: the plate's objects, by index (`object_list`), each "
"once, in the order wanted."}}},
{"descending", prop("boolean", "With by: descending order. Default false.")},
{"all", prop("boolean", "With by: order the objects of every plate. Default false: one plate's.")}}),
@@ -1967,7 +1969,7 @@ void register_object_menu_commands(CommandCatalog& catalog)
"Prepare view as one group, on plate, or with no arguments, as its Speed Dial action, on the current plate. A "
"group moves as one, its box to the plate's centre, its objects keeping their places relative to each other, so "
"a group spread over several plates and sent to plate may not fit on its bed. One undo step; the targets are "
"left selected. Reply: what it centred (objects, instances, parts) and the groups (plates: [{plate, objects}]).",
"left selected. Reply: what it centred (objects, instances, parts) and the groups (plates: [`{plate, objects}`]).",
with_targets(object_schema({{"plate", {{"type", "integer"}, {"minimum", 0}, {"description", "Centre them all on this plate."}}}}),
kObjects, false),
json::array({action("obj_center", L("Center Selected on Plate"), object_section, "", json::object(),
@@ -1981,7 +1983,7 @@ void register_object_menu_commands(CommandCatalog& catalog)
"Scale objects as one to fit the current plate's print volume and move them into it, as Scale to build volume does: "
"those named, else the objects and instances selected in the Prepare view. Cut objects and a bed of another shape "
"than a rectangle or a circle are refused. One undo step; the targets are left selected. Reply: what it scaled "
"(objects, instances) and each instance's scale (scales: [{object, instance, scale}]).",
"(objects, instances) and each instance's scale (scales: [`{object, instance, scale}`]).",
with_targets(object_schema({}), kObjects, false),
json::array({action("obj_fit_volume", L("Scale to Fit Print Volume"), object_section, "", json::object(),
"Scale the selection to fit the print volume.")}),
@@ -2002,7 +2004,7 @@ void register_object_menu_commands(CommandCatalog& catalog)
"objects that are not printable, none on a locked plate, leaves the job to turn every other object, as the "
"toolbar's does. "
"Waits for the job to end. One undo step; objects named are left selected. Reply: the objects it turned (objects) "
"and the rotation of each instance it turned (rotations: [{object, instance, rotation_deg}]).",
"and the rotation of each instance it turned (rotations: [`{object, instance, rotation_deg}`]).",
with_targets(object_schema({{"plates", array_prop({{"type", "integer"}}, "Plate indices: orient the objects that stand on them.")}}),
kObjects, false),
[](const json& args, ToolContext& ctx) {
@@ -2091,15 +2093,15 @@ void register_object_menu_commands(CommandCatalog& catalog)
with_expected_ids(menu_command(
"part_change_type", L("Change a part's type"),
"Change what parts are, as Change Type does: those named, else the part rows selected in the object list. type is "
"part, negative, modifier, support_blocker, support_enforcer, or precise_seam, a Center precise seam where a seam "
"keeps its subtype; subtype, with precise_seam alone, sets the seam's subtype as the Precise Seam Type menu does. "
"part, negative, modifier, `support_blocker`, `support_enforcer`, or `precise_seam`, a Center precise seam where a seam "
"keeps its subtype; subtype, with `precise_seam` alone, sets the seam's subtype as the Precise Seam Type menu does. "
"Not an object's last solid part; a text or SVG part does not become a support blocker or enforcer or a precise "
"seam; a painted modifier keeps its type. One undo step. Parts are listed by type, so part indices change. Reply: "
"each part with its index afterwards and its type (parts).",
with_targets(object_schema({{"type", enum_prop({"part", "negative", "modifier", "support_blocker", "support_enforcer", "precise_seam"},
"What the parts become.")},
{"subtype", enum_prop({"center", "left", "right", "enforced", "blocked", "neutral"},
"With type precise_seam: the seam's subtype, which every part named "
"With type `precise_seam`: the seam's subtype, which every part named "
"takes. Default: a seam keeps its own, another part becomes center.")}},
{"type"}),
kParts, false),
@@ -2187,8 +2189,8 @@ void register_object_tools(CommandCatalog& catalog)
"object_set_auto_drop", L("Set Auto Drop"),
"Turn Auto Drop on or off for objects, as the 3D view's Auto Drop does: those named, else the objects of what is "
"selected in the Prepare view, an instance or a part standing for its object. With it off an object stays where "
"object_transform or the Move gizmo leaves it, above the bed; with it on it drops onto the bed when it is next "
"moved. An object's instances share it. One undo step. Reply: the objects (objects) and auto_drop.",
"`object_transform` or the Move gizmo leaves it, above the bed; with it on it drops onto the bed when it is next "
"moved. An object's instances share it. One undo step. Reply: the objects (objects) and `auto_drop`.",
with_targets(object_schema({{"auto_drop", prop("boolean", "true lets the objects drop onto the bed, false lets them "
"stay above it.")}},
{"auto_drop"}),
@@ -2229,13 +2231,13 @@ void register_object_tools(CommandCatalog& catalog)
"object_fix", L("Fix Model"),
"Repair objects' meshes, as Fix Model does: those named (objects whole, or parts), the objects on a plate (plate, "
"as Fix All on the current plate), every object (all), else what is selected in the Prepare view, an instance "
"standing for its object. A painted modifier is left as it is, and painting is kept only with the keep_painting "
"standing for its object. A painted modifier is left as it is, and painting is kept only with the `keep_painting` "
"preference on. It opens no progress dialog and shows no notification; the call waits for the repair, during "
"which the window does not redraw, and job_cancel {job} cancels it: the call fails with the reply in its "
"which the window does not redraw, and `job_cancel {job}` cancels it: the call fails with the reply in its "
"details, and what was repaired before the cancel, a part of the object it stopped in among them, keeps its new "
"mesh. Refused while a gizmo is open. One undo step. Reply: what it repaired (objects, parts) and repairs, for "
"each in turn: changed, failed (why it could not be repaired), the object's mesh_errors_before and "
"mesh_errors_after (as object_list gives them), painting_removed, and cancelled: true on the one a cancel "
"each in turn: changed, failed (why it could not be repaired), the object's `mesh_errors_before` and "
"`mesh_errors_after` (as `object_list` gives them), `painting_removed`, and `cancelled: true` on the one a cancel "
"stopped, listed when its mesh had changed by then.",
with_targets(object_schema({{"plate", {{"type", "integer"},
{"minimum", 0},
@@ -2293,16 +2295,16 @@ void register_object_tools(CommandCatalog& catalog)
"Prepare view (an object whole, or some of its instances, which a copy holds as one new object). count copies of "
"each (default 1, as the dialog's field starts), added after the other objects, placed near them on the current "
"plate; the last copies are left selected. With arrange true the current plate is then arranged, as the dialog's "
"Auto arrange plate after cloning does; without arrange, the dialog's choice: the auto_arrange preference. The "
"Auto arrange plate after cloning does; without arrange, the dialog's choice: the `auto_arrange` preference. The "
"call waits for the arrangement. One undo step for the copies, and one for the arrangement. Reply: the new objects "
"(objects), what was copied (copied: its objects, or its instances where instances were selected), object_count "
"(objects), what was copied (copied: its objects, or its instances where instances were selected), `object_count` "
"and arranged.",
with_targets(object_schema({{"count", {{"type", "integer"},
{"minimum", 1},
{"maximum", 1000},
{"description", "Copies of each, up to 1000 as the Clone dialog takes. Default 1."}}},
{"arrange", prop("boolean", "Arrange the current plate afterwards. Default: the Clone dialog's "
"choice, the auto_arrange preference.")}}),
"choice, the `auto_arrange` preference.")}}),
kObjects, false),
[](const json& args, ToolContext& ctx) {
AutomationRuntime& runtime = ctx.runtime();
@@ -2363,7 +2365,7 @@ void register_object_tools(CommandCatalog& catalog)
"named, the parts named, every object's (all, as Reload All does, cut objects left out), else what is selected in "
"the Prepare view. A part's file is the one it was loaded from, else the file of that name beside its object's "
"file. A part whose file is gone is not asked for: it is listed under missing. A part keeps its settings, type, "
"filament and placement, and its painting when the keep_painting preference is on. Parts loaded from no file "
"filament and placement, and its painting when the `keep_painting` preference is on. Parts loaded from no file "
"(primitives, the built-in models) are left out; cut objects are refused, since a reload would replace a cut part "
"with its whole file, and so is a call while a gizmo is open. One undo step, none when every part's file is "
"missing and nothing is reloaded. Reply: reloaded (parts), missing "
@@ -2424,12 +2426,12 @@ void register_object_tools(CommandCatalog& catalog)
"part_replace", L("Replace 3D file"),
"Replace a part's mesh with the mesh of a model file, as Replace 3D file does: the part named (object and part, or "
"an object of one part), else the one selected in the Prepare view. The part keeps its settings, type, filament "
"and placement, and its painting when the keep_painting preference is on; with it off the painting is copied as it "
"and placement, and its painting when the `keep_painting` preference is on; with it off the painting is copied as it "
"is, which fits the same mesh alone. A file that loads as more than one object or part is refused, as Replace 3D "
"file refuses it. path names the file, so no file dialog opens; the loader may still ask, a STEP file for its mesh "
"options (blocked_by_dialog). Cut objects are refused, and so is a call while a gizmo is open. One undo step. "
"Reply: the part (parts), with its new part_id and its index, which moves when the object's parts are not in type "
"order (the replacement sorts them), and its object_list entry (part_info).",
"options (`blocked_by_dialog`). Cut objects are refused, and so is a call while a gizmo is open. One undo step. "
"Reply: the part (parts), with its new `part_id` and its index, which moves when the object's parts are not in type "
"order (the replacement sorts them), and its `object_list` entry (`part_info`).",
with_targets(object_schema({{"path", prop("string", "Absolute path of the model file (STL, OBJ, 3MF, STEP, ...).")}}, {"path"}),
kParts, true),
[](const json& args, ToolContext& ctx) {
@@ -2470,34 +2472,33 @@ void register_scene_tools(CommandCatalog& catalog)
{
catalog.add(inspect_tool(
"object_list", L("List objects"),
"The project as the Objects panel lists it. plates: each {index, name, objects}, with the objects that have an "
"instance on it; outside: the objects with an instance on no plate. An object with instances on two plates is "
"listed under both, each time with that plate's instances. An object has its index, id, name, filament, "
"part_count, size (mm, of the bounding box below) and instances, the indices of its instances there. With detail, "
"an object has its filament, auto_drop, bounding box "
"(instance 0), brim ear count and overrides, the keys of the settings it overrides (settings_get target object "
"reads them); its mesh_errors, as the list's warning icon reads them: open_edges, manifold (no open edge), and the "
"loader's or a repair's counts degenerate_facets, edges_fixed, facets_removed, facets_reversed and "
"backwards_edges (object_fix repairs it); its instances as entries (index, offset, rotation in degrees, scale, "
"mirrored, bbox); its parts, one or more: parts, negative parts, modifiers, support blockers and enforcers and "
"precise seams (type, with subtype for a precise seam; filament: a part's own or its object's, a modifier's only when it sets "
"one; position, bbox and scaled_volume in mm3 on the bed, measured on instance 0; rotation_deg and scale in the "
"object's frame; mirrored; triangle count; mesh_volume, the unscaled mesh's mm3; painted facets: supports and "
"seam enforcers/blockers, fuzzy_skin, mmu per filament, texture per layer; a text part's text and font, an SVG "
"part's file); its height range modifiers when it has any (layer_config_ranges: [{min_z, max_z, values}], values "
"being a range's settings, which settings_set changes with target height_range; object_set_height_ranges takes "
"min_z and max_z) and its variable layer height profile when it has one (layer_height_profile: "
"{points, min_height, max_height}). A bbox is {min, max, size} in mm of model parts only, so unlike the panel's Size it "
"The project as the Objects panel lists it. `plates`: each `{index, name, objects}`, with the objects that have an "
"instance on it; `outside`: the objects with an instance on no plate. An object with instances on two plates is "
"listed under both, each time with that plate's instances. An object has its `index`, `id`, `name`, `filament`, "
"`part_count`, `size` (mm, of the bounding box below) and `instances`, the indices of its instances there. With "
"`detail`, an object has its `filament`, `auto_drop`, `bbox` (instance 0), `brim_ears` (a count) and `overrides`, "
"the keys of the settings it overrides (`settings_get` target object reads them); its `mesh_errors`, as the list's warning icon reads them: `open_edges`, manifold (no open edge), and the "
"loader's or a repair's counts `degenerate_facets`, `edges_fixed`, `facets_removed`, `facets_reversed` and "
"`backwards_edges` (`object_fix` repairs it); its `instances` as entries (`index`, `offset`, `rotation_deg`, `scale`, "
"`mirrored`, `bbox`); its `parts`, one or more: parts, negative parts, modifiers, support blockers and enforcers and "
"precise seams (`type`, with `subtype` for a precise seam; `filament`: a part's own or its object's, a modifier's only when it sets "
"one; `position`, `bbox` and `scaled_volume` in mm3 on the bed, measured on instance 0; `rotation_deg` and `scale` in the "
"object's frame; `mirrored`; `triangles`, a count; `mesh_volume`, the unscaled mesh's mm3; `painted` facets: supports and "
"seam enforcers/blockers, `fuzzy_skin`, mmu per filament, texture per layer; a text part's text and font, an SVG "
"part's file); its height range modifiers when it has any (`layer_config_ranges`: [`{min_z, max_z, values}`], values "
"being a range's settings, which `settings_set` changes with target `height_range`; `object_set_height_ranges` takes "
"`min_z` and `max_z`) and its variable layer height profile when it has one (`layer_height_profile`: "
"`{points, min_height, max_height}`). A bbox is `{min, max, size}` in mm of model parts only, so unlike the panel's Size it "
"leaves out modifiers. An object's index numbers it in the project and a part's in its object, whatever the plate: "
"they are what object_select, object_transform, mouse_gesture targets and the settings tools' object and part targets take. "
"they are what `object_select`, `object_transform`, `mouse_gesture` targets and the settings tools' object and part targets take. "
"Each object and part also has an id, which stays with it when a delete, split or assemble shifts the indices: pass "
"it as object_id / part_id to object_transform, part_add, settings_set, object_set_height_ranges and object_set_variable_layer_height "
"(object_ids, part_ids and instance_object_ids to object_select), and a call whose index names another one now is "
"refused instead of acting on it. limit and offset page the objects and total counts them, each once.",
object_schema({{"plate", {{"type", "integer"}, {"minimum", 0}, {"description", "List this plate alone, without outside."}}},
"it as `object_id` / `part_id` to `object_transform`, `part_add`, `settings_set`, `object_set_height_ranges` and `object_set_variable_layer_height` "
"(`object_ids`, `part_ids` and `instance_object_ids` to `object_select`), and a call whose index names another one now is "
"refused instead of acting on it. `limit` and `offset` page the objects and `total` counts them, each once.",
object_schema({{"plate", {{"type", "integer"}, {"minimum", 0}, {"description", "List this plate alone, without `outside`."}}},
{"detail", prop("boolean", "Each object whole: its instances, parts, bounding boxes, mesh errors, paint and "
"overrides (default false).")},
{"screen", prop("boolean", "Add each instance's rectangle in the shown 3D view, logical pixels [x, y, w, h], "
{"screen", prop("boolean", "Add each instance's rectangle in the shown 3D view, logical pixels `[x, y, w, h]`, "
"to its entry, as with detail.")},
{"limit", {{"type", "integer"}, {"minimum", 1}, {"maximum", 500}, {"description", "Objects, default 200."}}},
{"offset", {{"type", "integer"}, {"minimum", 0}}}}),
@@ -2506,10 +2507,10 @@ void register_scene_tools(CommandCatalog& catalog)
NativeCommand select = with_expected_ids(mutate_tool(
"object_select", L("Select objects"),
"Select objects, instances or parts in the 3D view (the assemble view while it is shown, else Prepare, switching to it), as clicking them would. Give objects, "
"instances ([[object, instance], ...]) or parts ([[object, part], ...]); add keeps the current selection; all / "
"instances (`[[object, instance], ...]`) or parts (`[[object, part], ...]`); add keeps the current selection; all / "
"none select everything or nothing, whatever else is given; none also closes the open gizmo, as Deselect All does, "
"and all is refused while a gizmo that keeps its selection is open. The reply is the selection as "
"app_state.selection gives it, for all and none alone (Select All and Deselect All) too.",
"`app_state.selection` gives it, for all and none alone (Select All and Deselect All) too.",
with_targets(object_schema({{"add", prop("boolean", "Add to the selection instead of replacing it.")},
{"all", prop("boolean", "Select all objects.")},
{"none", prop("boolean", "Clear the selection and close the open gizmo.")}}),
@@ -2588,22 +2589,22 @@ void register_scene_tools(CommandCatalog& catalog)
"object_transform", L("Move, rotate or scale an instance or a part"),
"Change one instance's placement, or one part's with part. translate is in mm, position where it goes (mm, as "
"the Move panel shows it, whatever mode says), rotate in degrees about X/Y/Z, "
"scale a factor (one number or [x, y, z]), size [x, y, z] mm along the object's or part's own axes, plate moves "
"scale a factor (one number or `[x, y, z]`), size `[x, y, z]` mm along the object's or part's own axes, plate moves "
"the instance onto that plate at the same place. mode \"relative\" (default) adds to the current placement (a scale "
"multiplies it), \"absolute\" sets it. An instance is dropped back onto the bed, unless its object's auto_drop is "
"off; drop_to_bed false lets it sink into the bed, but an object of one part left above the bed still drops. A part "
"multiplies it), \"absolute\" sets it. An instance is dropped back onto the bed, unless its object's `auto_drop` is "
"off; `drop_to_bed` false lets it sink into the bed, but an object of one part left above the bed still drops. A part "
"moves as the "
"Object manipulation panel moves it: translate and rotate along the bed's axes, measured on instance 0, scale and "
"size along its own axes; every instance shows the change, and Auto Drop may lower the object afterwards. The "
"instance is the object's instance (default 0) and the part one of its parts; with no object, the instance or part "
"selected in the Prepare view, or instance 0 of the object selected. One undo step. Reply: the instance's offset, "
"scale and plate, or the part's size along its own axes and its object_list entry (part_info), and what it moved "
"scale and plate, or the part's size along its own axes and its `object_list` entry (`part_info`), and what it moved "
"(instances or parts).",
with_targets(object_schema({{"translate", array_prop({{"type", "number"}}, "[x, y, z] mm")},
{"position", array_prop({{"type", "number"}}, "[x, y, z] mm: the position to move to. Not with translate.")},
{"rotate", array_prop({{"type", "number"}}, "[x, y, z] degrees; relative only for a part")},
{"scale", {{"type", {"number", "array"}}, {"description", "Factor or [x, y, z] factors."}}},
{"size", array_prop({{"type", {"number", "null"}}}, "[x, y, z] mm, null keeps an axis; one number "
{"position", array_prop({{"type", "number"}}, "`[x, y, z]` mm: the position to move to. Not with translate.")},
{"rotate", array_prop({{"type", "number"}}, "`[x, y, z]` degrees; relative only for a part")},
{"scale", {{"type", {"number", "array"}}, {"description", "Factor or `[x, y, z]` factors."}}},
{"size", array_prop({{"type", {"number", "null"}}}, "`[x, y, z]` mm, null keeps an axis; one number "
"and two nulls keep the proportions. Not with scale.")},
{"plate", {{"type", "integer"}, {"minimum", 0}, {"description", "Move the instance to this plate."}}},
{"mode", enum_prop({"relative", "absolute"}, "Default relative.")},
@@ -2653,19 +2654,19 @@ void register_scene_tools(CommandCatalog& catalog)
"menu puts it (a shape beside the object, a file at its coordinates relative to the object's first part) unless "
"position is given. Like the menu, adding a shape folds the instance's rotation and scale into the object's parts "
"(the instance's scale then reads 1). Refused for an object with several instances: add parts first. A STEP file "
"may ask for mesh options (blocked_by_dialog). The object is the one named, else the one selected in the Prepare "
"may ask for mesh options (`blocked_by_dialog`). The object is the one named, else the one selected in the Prepare "
"view, or the object of the selected instance or part. The new part is selected; one undo step. Reply: its index, "
"which is not always the last (parts are ordered by type), the object's part count and the part's object_list entry "
"(part_info), and the object (objects).",
"which is not always the last (parts are ordered by type), the object's part count and the part's `object_list` entry "
"(`part_info`), and the object (objects).",
with_targets(object_schema({{"type", enum_prop({"part", "negative", "modifier", "support_blocker", "support_enforcer", "precise_seam"},
"What the new part is.")},
{"shape", enum_prop({"cube", "cylinder", "sphere", "cone", "disc", "torus"}, "A primitive shape.")},
{"size", array_prop({{"type", "number"}}, "mm, the Primitive size dialog's fields: cube [x, y, z]; "
"cylinder, cone, disc [diameter, height]; sphere "
"[diameter]; torus [inner diameter, tube diameter]. "
{"size", array_prop({{"type", "number"}}, "mm, the Primitive size dialog's fields: cube `[x, y, z]`; "
"cylinder, cone, disc `[diameter, height]`; sphere "
"`[diameter]`; torus `[inner diameter, tube diameter]`. "
"Default: the built-in size.")},
{"path", prop("string", "Instead of shape: absolute path of a model file (STL, OBJ, 3MF, STEP, ...).")},
{"position", array_prop({{"type", "number"}}, "[x, y, z] mm on the bed for the part's centre, on "
{"position", array_prop({{"type", "number"}}, "`[x, y, z]` mm on the bed for the part's centre, on "
"instance 0, as the Move panel shows it.")}},
{"type"}),
kObjects, true),
@@ -2690,11 +2691,11 @@ void register_scene_tools(CommandCatalog& catalog)
NativeCommand arrange = reaching({"start_arrange"}, mutate_tool(
"object_arrange", L("Arrange objects or fill the bed"),
"Arrange the objects of every unlocked plate as the toolbar's Arrange does, or of one plate (plates: an index or "
"\"current\") as its Arrange icon does. With fill_object, fill that object's plate with more of it instead, as Fill "
"bed with instances (or copies, by fill_with) does (reply: added, how many). spacing, rotate, align_y and multi_material are the Arrange options "
"\"current\") as its Arrange icon does. With `fill_object`, fill that object's plate with more of it instead, as Fill "
"bed with instances (or copies, by `fill_with`) does (reply: added, how many). spacing, rotate, `align_y` and `multi_material` are the Arrange options "
"panel's settings: the values given stay in the panel, so later arranges use them too. Waits for the arrangement "
"(a longer one replies with a job). Reply: the settings in force, instances left off every plate, plates the "
"all-plates arrange skipped and the job's notifications. An arrange may reorder objects, so object_list again. "
"all-plates arrange skipped and the job's notifications. An arrange may reorder objects, so `object_list` again. "
"One undo step. Called with no arguments it is Auto-Arrange, the toolbar's Arrange with the panel's settings, and "
"waits and replies as any other call.",
object_schema({{"plates", {{"type", {"string", "integer"}}, {"description", "\"all\" (default), \"current\" or a plate index."}}},
@@ -2753,14 +2754,14 @@ void register_scene_tools(CommandCatalog& catalog)
"Slice the current plate, all plates, or one plate by index, the way the toolbar's Slice button does, and wait for "
"the result (or reply with a job id when it takes longer than the reply budget). Each requested plate reports ok, "
"error, cancelled, empty or skipped; the whole operation is superseded when someone else started a slice or "
"edited the project while it ran. An ok plate has time_s (silent_time_s when the printer estimates it), "
"filament_m and filament_g including flush, filament_cost, layers, max_z, filament_changes, and filaments[i] for "
"slot i+1 with m, g and the grams of model_g, support_g, flush_g and tower_g. Other changes are refused until it "
"finishes; job_cancel stops it. The Preview tab shows the result, as after the Slice button; preview: true, alone "
"edited the project while it ran. An ok plate has `time_s` (`silent_time_s` when the printer estimates it), "
"`filament_m` and `filament_g` including flush, `filament_cost`, layers, `max_z`, `filament_changes`, and filaments[i] for "
"slot i+1 with m, g and the grams of `model_g`, `support_g`, `flush_g` and `tower_g`. Other changes are refused until it "
"finishes; `job_cancel` stops it. The Preview tab shows the result, as after the Slice button; `preview: true`, alone "
"or with plates \"all\", is the call of Slice and Preview or Slice All Plates, whose pick starts the slice as a job "
"and shows its result as a notification.",
object_schema({{"plates", {{"type", {"string", "integer"}}, {"description", "\"current\" (default), \"all\", or a plate index."}}},
{"timeout_s", {{"type", "integer"}, {"minimum", 10}, {"maximum", 7200}, {"description", "Stop waiting after this long (default 1800): the call fails, and the slice goes on unless job_cancel stops it."}}},
{"timeout_s", {{"type", "integer"}, {"minimum", 10}, {"maximum", 7200}, {"description", "Stop waiting after this long (default 1800): the call fails, and the slice goes on unless `job_cancel` stops it."}}},
{"preview", prop("boolean", "Show the Preview tab, as every slice does: the argument of the Slice and "
"Preview and Slice All Plates actions.")}}),
[](const json& args, ToolContext& ctx) {
@@ -2892,8 +2893,8 @@ void register_scene_tools(CommandCatalog& catalog)
"Stop the running operation: a slice or G-code export, as the slicing progress's cancel button does, or a "
"background job an MCP call started (an arrange, orient or fill bed). Its job then reports cancelled; a background "
"job keeps other changes out until it has really stopped. With job, only that job is stopped: the running "
"operation, an object_fix, a script_run run or a recording_encode. Allowed while an operation holds the project. Reply: "
"was_running, and job when one was stopped.",
"operation, an `object_fix`, a `script_run` run or a `recording_encode`. Allowed while an operation holds the project. Reply: "
"`was_running`, and job when one was stopped.",
object_schema({{"job", prop("string", "The operation's job to cancel, e.g. \"j12\".")}}),
[](const json& args, ToolContext& ctx) {
AutomationRuntime& runtime = ctx.runtime();
+79 -79
View File
@@ -71,14 +71,14 @@ namespace {
// The locator grammar is spelled out once, in widget_list's description, which hands out the refs, and that a ref
// stays good across later listings in the server instructions.
const json kTargetSchema = {{"type", json::array({"string", "object"})},
{"description", "A ref widget_list gave (\"w12\") or a locator, such as {label: \"OK\", within: "
"\"Preferences\"} or {menu: \"File>Export>Export G-code\"}; widget_list's description "
{"description", "A ref `widget_list` gave (\"w12\") or a locator, such as `{label: \"OK\", within: "
"\"Preferences\"}` or `{menu: \"File>Export>Export G-code\"}`; `widget_list`'s description "
"lists every kind."}};
// webview_run_javascript's target: a web view or an element of its page, not a widget.
const json kPageTargetSchema = {{"type", json::array({"string", "object"})},
{"description", "A web view (its ref; widget_list lists it as kind webview) or an element of its "
"page (its ref or a {web} / {css} locator), which the code gets as `el`. Default: "
{"description", "A web view (its ref; `widget_list` lists it as kind webview) or an element of its "
"page (its ref or a `{web}` / `{css}` locator), which the code gets as `el`. Default: "
"the topmost dialog's web view, else the only one shown."}};
const json kPageTimeoutSchema = {{"type", "integer"},
@@ -88,7 +88,7 @@ const json kPageTimeoutSchema = {{"type", "integer"},
const json kModifiersSchema = {{"type", "array"},
{"items", {{"type", "string"}, {"enum", {"ctrl", "cmd", "rawctrl", "shift", "alt"}}}},
{"description", "Modifier keys held during the input, as in keyboard_press: ctrl and cmd are both Command on macOS "
{"description", "Modifier keys held during the input, as in `keyboard_press`: ctrl and cmd are both Command on macOS "
"and Ctrl elsewhere; rawctrl is the macOS Control key."}};
bool in_top_dialog(AutomationRuntime& runtime, wxWindow* window)
@@ -132,7 +132,7 @@ NativeCommand recover_input_tool(std::string name, std::string title, std::strin
const json kPopupItemSchema = prop("string", "The item to run of a menu the input opens (a context menu, a button's menu), by "
"label path (\"Add Modifier>Cylinder\"; \"#2\": a repeated label's second). Without "
"it the reply lists the menu (popup_menu) instead of showing it.");
"it the reply lists the menu (`popup_menu`) instead of showing it.");
// The menu an input call may open, which the inspector takes instead of showing it
// (UiInspector::arm_menu()): armed in the closure that delivers the input, read once the events the
@@ -1351,13 +1351,13 @@ void register_ui_tools(CommandCatalog& catalog)
"window_list", L("List the windows"),
"List OrcaSlicer's open windows: the main window, then the windows that don't block the app (Plugins, an "
"object's settings, a dock panel floating on its own), then the modal dialogs in the order they opened, the "
"topmost last. A window's ref goes to window_screenshot as target to capture that window, to widget_list as target to "
"list it alone, and to keyboard_press as target; its title is the within of locators for its widgets.\n"
"topmost last. A window's ref goes to `window_screenshot` as target to capture that window, to `widget_list` as target to "
"list it alone, and to `keyboard_press` as target; its title is the within of locators for its widgets.\n"
"Reply: each window's title, kind (main, window, dialog, or panel: a dock panel floating on its own), modal, "
"ref, web (it shows a web page), x and y on screen (not on Wayland, which doesn't say), width and height, state "
"(normal, maximized or minimized) and resizable (it has a resize border); window_set changes them.\n"
"A native dialog (a message box, a file picker) has native: true and no ref: dialog_answer answers it. hidden: "
"true marks the person's own windows (the Run Script panel floating, its prompts and Action Replay's, the Python "
"(normal, maximized or minimized) and resizable (it has a resize border); `window_set` changes them.\n"
"A native dialog (a message box, a file picker) has `native: true` and no ref: `dialog_answer` answers it. `hidden: "
"true` marks the person's own windows (the Run Script panel floating, its prompts and Action Replay's, the Python "
"scripts setting), which no tool reaches and screenshots leave out.",
object_schema({{"limit", {{"type", "integer"}, {"minimum", 1}, {"maximum", 200}, {"description", "Default 100."}}},
{"offset", {{"type", "integer"}, {"minimum", 0}}}}),
@@ -1370,9 +1370,9 @@ void register_ui_tools(CommandCatalog& catalog)
NativeCommand def = recover_input_tool(
"window_set", L("Size, move or raise a window"),
"Size, move, maximize, minimize or raise a window: the main window (default), the topmost modal dialog, or one "
"window_list lists, also while a modal dialog is open. Size the main window before view_set fits the camera and "
"before recording_start, as a recording keeps its first frame's size. size and position are in the units "
"window_list reports, whose x/y and width/height are read as position and size too. A size or position restores "
"`window_list` lists, also while a modal dialog is open. Size the main window before `view_set` fits the camera and "
"before `recording_start`, as a recording keeps its first frame's size. size and position are in the units "
"`window_list` reports, whose x/y and width/height are read as position and size too. A size or position restores "
"a maximized or minimized window first. A window takes only the states its title bar offers; a modal dialog "
"never minimizes. A refused call changes nothing. Replies once the window holds still and the 3D view has drawn "
"at its new size (3 s at most): title, kind, ref, size, position, state, resizable, scale (screenshot pixels per "
@@ -1380,10 +1380,10 @@ void register_ui_tools(CommandCatalog& catalog)
"changed.",
object_schema({{"target", {{"type", json::array({"string", "object"})},
{"description", "main (default), dialog (the topmost modal "
"dialog), or a window's ref or locator from window_list; a widget's ref or "
"dialog), or a window's ref or locator from `window_list`; a widget's ref or "
"locator picks the window it is in."}}},
{"size", array_prop({{"type", "integer"}}, "[width, height], held to the window's minimum and maximum size.")},
{"position", array_prop({{"type", "integer"}}, "[x, y] of the window's top-left corner on screen; not on Wayland.")},
{"size", array_prop({{"type", "integer"}}, "`[width, height]`, held to the window's minimum and maximum size.")},
{"position", array_prop({{"type", "integer"}}, "`[x, y]` of the window's top-left corner on screen; not on Wayland.")},
{"state", enum_prop({"normal", "maximized", "minimized"},
"normal restores a maximized or minimized window; maximized and minimized take no size "
"or position.")},
@@ -1397,37 +1397,37 @@ void register_ui_tools(CommandCatalog& catalog)
{
NativeCommand def = inspect_tool(
"widget_list", L("List the widgets"),
"Describe what is on screen as an indented tree, one element per line with a ref to pass to widget_click, widget_set_value, "
"keyboard_press and webview_run_javascript (a page element's to mouse_gesture too): the widgets of every shown window, the rows of lists, "
"Describe what is on screen as an indented tree, one element per line with a ref to pass to `widget_click`, `widget_set_value`, "
"`keyboard_press` and `webview_run_javascript` (a page element's to `mouse_gesture` too): the widgets of every shown window, the rows of lists, "
"trees and tables, each shown popup after the window it opened from, the main menus, the 3D canvas's toolbar "
"items and gizmos, each ImGui panel drawn in the last frame with its items and text, and the elements of each "
"shown web page (dialogs, the setup wizard, sign-in, plugin windows) under its web view. With a modal dialog "
"open, only the topmost dialog's pages are read. Refs go stale when their element goes away: call widget_list "
"again then. Prefer action_run and the typed tools when one fits.\n"
"A locator names an element without a ref, in any session (replay_export records them); index (0-based) picks "
"open, only the topmost dialog's pages are read. Refs go stale when their element goes away: call `widget_list` "
"again then. Prefer `action_run` and the typed tools when one fits.\n"
"A locator names an element without a ref, in any session (`replay_export` records them); index (0-based) picks "
"one of several matches:\n"
"- a widget: {label, class, name, within, index}, within being its window's title; a notebook page: {tab: "
"\"General\", within}\n"
"- a setting's field: {option: \"layer_height\"}\n"
"- {menu: \"File>Export>Export G-code\"}, {gltoolbar: \"arrange\"}, {gizmo: \"Move\"}\n"
"- an ImGui item: {imgui: \"label\", imgui_name?: \"name\", window?, canvas?, index?}, by its label, its name or both\n"
"- a row of a list, tree, table or drop-down list: {row: \"Plate 1>Cube>Cylinder\", column?, within?, index?}, by "
"- a widget: `{label, class, name, within, index}`, within being its window's title; a notebook page: `{tab: "
"\"General\", within}`\n"
"- a setting's field: `{option: \"layer_height\"}`\n"
"- `{menu: \"File>Export>Export G-code\"}`, `{gltoolbar: \"arrange\"}`, `{gizmo: \"Move\"}`\n"
"- an ImGui item: `{imgui: \"label\", imgui_name?: \"name\", window?, canvas?, index?}`, by its label, its name or both\n"
"- a row of a list, tree, table or drop-down list: `{row: \"Plate 1>Cube>Cylinder\", column?, within?, index?}`, by "
"its last labels; column names the cell to act on\n"
"- a plate or one of its icons in the Prepare view: {plate_icon: \"lock\", plate: 0}, the icon being plate, "
"delete, orient, arrange, lock, settings, name, move_to_front, filament_map or imex_mode\n"
"- a web page's element: {web: \"Next\", kind?: \"button\", css?: \"#AcceptBtn\", within?, index?}, by the label "
"widget_list lists (exactly, else ignoring case, else a part of it), its kind, a CSS selector (the id a line "
"shows as name: name=#save is {css: \"#save\"}), or together. Without within it looks in the topmost dialog's "
"- a plate or one of its icons in the Prepare view: `{plate_icon: \"lock\", plate: 0}`, the icon being plate, "
"delete, orient, arrange, lock, settings, name, `move_to_front`, `filament_map` or `imex_mode`\n"
"- a web page's element: `{web: \"Next\", kind?: \"button\", css?: \"#AcceptBtn\", within?, index?}`, by the label "
"`widget_list` lists (exactly, else ignoring case, else a part of it), its kind, a CSS selector (the id a line "
"shows as name: name=#save is `{css: \"#save\"}`), or together. Without within it looks in the topmost dialog's "
"pages while one is open, else in every shown page, and an action on it waits for its element up to 2 s short of "
"the action's timeout_s (8 s by default), but at least 3 s or the whole of a shorter timeout_s.",
object_schema({{"target", prop("string", "all (default), main, dialog (the topmost modal), popup, or a window's ref (window_list).")},
"the action's `timeout_s` (8 s by default), but at least 3 s or the whole of a shorter `timeout_s`.",
object_schema({{"target", prop("string", "all (default), main, dialog (the topmost modal), popup, or a window's ref (`window_list`).")},
{"query", prop("string", "Case-insensitive text to look for in labels, values, names and classes.")},
{"max_nodes", {{"type", "integer"}, {"minimum", 1}, {"maximum", 5000}, {"description", "Default 400."}}},
{"include_imgui", prop("boolean", "List ImGui items (default true).")},
{"include_menus", prop("boolean", "List menu items (default true).")},
{"include_web", prop("boolean", "List the elements of web pages (default true).")},
{"max_web_nodes",
{{"type", "integer"}, {"minimum", 1}, {"maximum", 5000}, {"description", "Page elements, apart from max_nodes; default 300."}}}}),
{{"type", "integer"}, {"minimum", 1}, {"maximum", 5000}, {"description", "Page elements, apart from `max_nodes`; default 300."}}}}),
[](const json& args, ToolContext& ctx) {
AutomationRuntime& runtime = ctx.runtime();
SnapshotOptions o;
@@ -1494,18 +1494,18 @@ void register_ui_tools(CommandCatalog& catalog)
"selected as a click on its cell selects it (ctrl adds, shift extends; in the object list the named column acts, as "
"Printable toggles), double activates it and a right click opens its menu; a drop-down list's row is picked. A "
"plate icon does what it does in the Prepare view: lock replies locked, arrange and orient reply done once their "
"job ends, settings and filament_map list the dialog they open (dialogs). A button, checkbox, toggle or radio "
"job ends, settings and `filament_map` list the dialog they open (dialogs). A button, checkbox, toggle or radio "
"button is activated so by a plain left click only: with modifiers, double or another button it gets a mouse "
"click, which a native control ignores. A menu item runs whatever those options are, a toolbar item takes a "
"left or a right click, and a gizmo a single left one. Modifiers reach the 3D canvas, the object list and "
"handlers that read them. To click a point of the model, drag, scroll or hold a press, use mouse_gesture. A menu the click opens is "
"never shown: the reply lists it as popup_menu, or "
"popup_item runs one of its items (ran). A click that opens a dialog replies blocked_by_dialog.\n"
"handlers that read them. To click a point of the model, drag, scroll or hold a press, use `mouse_gesture`. A menu the click opens is "
"never shown: the reply lists it as `popup_menu`, or "
"`popup_item` runs one of its items (ran). A click that opens a dialog replies `blocked_by_dialog`.\n"
"A web page's element gets the pointer and mouse events of a click at its centre (or x/y) once scrolled into view, "
"refused when something else covers that point. The reply reads back checked, and has closed when the click closed "
"its dialog (with dialogs, those still open under it, which still need an answer), navigated (with url) when it "
"changed the page, or dialogs when it opened another. Otherwise page says what changed on the page within 300 ms: "
"changed (false when its lines are as before), the widget_list lines added and removed, partial when a plugin "
"changed (false when its lines are as before), the `widget_list` lines added and removed, partial when a plugin "
"configuration frame could not be compared, and posted, how many messages the page sent OrcaSlicer.",
object_schema({{"target", kTargetSchema},
{"button", enum_prop({"left", "right", "middle"}, "Default left.")},
@@ -1609,9 +1609,9 @@ void register_ui_tools(CommandCatalog& catalog)
"replies typed and a note beside it; a combo's option is picked by its text or 0-based index, and a checkbox, radio "
"or toggle is clicked when it differs. A web page's fields, as typing would leave them: text, number, range, colour "
"and date fields and editable text get the value with input and change events (submit then leaves the field; "
"keyboard_press Return presses Enter), a select its option by text, value or index, and a checkbox or radio is clicked when "
"it differs; the value is read back and page says what changed, as for widget_click. File fields can't be set. For "
"settings, settings_set is more reliable.",
"`keyboard_press` Return presses Enter), a select its option by text, value or index, and a checkbox or radio is clicked when "
"it differs; the value is read back and page says what changed, as for `widget_click`. File fields can't be set. For "
"settings, `settings_set` is more reliable.",
object_schema({{"target", kTargetSchema},
{"value", {{"type", json::array({"string", "number", "boolean"})}, {"description", "The new value."}}},
{"submit", prop("boolean", "Press Enter / commit after setting (default true).")},
@@ -1639,11 +1639,11 @@ void register_ui_tools(CommandCatalog& catalog)
"Send a key chord (\"Ctrl+S\", \"Escape\", \"Return\", \"Delete\", \"Shift+Tab\", \"Left\", \"F5\") and/or type text to "
"a target or, without one, to the focused window (the topmost dialog while one is open, the shown 3D view when "
"nothing has focus). As with a real key press, the shortcut handling of the target's panels and window sees the keys "
"first. Typing reaches ImGui fields and key handlers; fill a widget's text field with widget_set_value. A menu the keys open "
"is listed as popup_menu, or popup_item runs one of its items. Keys for a web page (its element, or without a "
"first. Typing reaches ImGui fields and key handlers; fill a widget's text field with `widget_set_value`. A menu the keys open "
"is listed as `popup_menu`, or `popup_item` runs one of its items. Keys for a web page (its element, or without a "
"target the focused web view or the topmost dialog's only page) go to the page's focused element with the "
"browser's default actions: typing, Backspace/Delete, Enter (submits a form, activates a button), Space, Tab moving "
"the focus, arrows stepping a select, range or radio group; page says what they changed, as for widget_click.",
"the focus, arrows stepping a select, range or radio group; page says what they changed, as for `widget_click`.",
object_schema({{"target", kTargetSchema},
{"keys", prop("string", "One chord: a key, after any modifiers joined by +. Keys: one character, Enter, Esc, "
"Tab, Space, Backspace, Delete, Insert, Home, End, PageUp, PageDown, Left, Right, "
@@ -1697,7 +1697,7 @@ void register_ui_tools(CommandCatalog& catalog)
const json target_schema = {
{"type", "object"},
{"description", "A point of the model: {object, instance (default 0), part (default 0), and point [x, y, z] in "
{"description", "A point of the model: {object, instance (default 0), part (default 0), and point `[x, y, z]` in "
"the part's own mesh coordinates (frame \"part\", the default) or the scene's (frame \"world\"), or "
"spot: top | bottom | front | back | left | right, where a ray along that axis first meets the part}."},
{"properties",
@@ -1710,7 +1710,7 @@ void register_ui_tools(CommandCatalog& catalog)
{"required", {"object"}},
{"additionalProperties", false}};
const json pixel_or_target = {{"type", json::array({"array", "object"})},
{"description", "A canvas pixel [x, y] or a point of the model, as for at."}};
{"description", "A canvas pixel `[x, y]` or a point of the model, as for at."}};
std::vector<std::string> mouse_canvases{"3d", "preview", "assemble", "current"};
#ifdef SLIC3R_CAD
mouse_canvases.insert(mouse_canvases.end() - 1, "design");
@@ -1722,16 +1722,16 @@ void register_ui_tools(CommandCatalog& catalog)
"\"point\" only projects it), or at x/y, logical pixels from the canvas's top left. A drag goes through `waypoints` to "
"`to`, `steps` moves per leg: on an object it moves the object, in a painting gizmo it paints from a press on the "
"object being painted (waypoints zigzagging over an area paint all of it), and elsewhere it turns or pans the camera "
"as this install's mouse settings say, so turn the camera with view_set camera or orbit instead. A wheel turns delta "
"as this install's mouse settings say, so turn the camera with `view_set` camera or orbit instead. A wheel turns delta "
"notches; positive zooms in (out with the Reverse mouse zoom preference on) or scrolls a panel up. Modifiers are "
"held as keys for the gesture (shift picks points in Measure and erases in a painting gizmo). A down keeps its button and modifiers held, so moves drag, until an up or another "
"gesture. Grabbers are set through the gizmo's panel fields or object_transform, not dragged. A menu a right click opens "
"is listed as popup_menu, or popup_item (with click or up) runs one of its items. The reply's camera_moved says the "
"gesture. Grabbers are set through the gizmo's panel fields or `object_transform`, not dragged. A menu a right click opens "
"is listed as `popup_menu`, or `popup_item` (with click or up) runs one of its items. The reply's `camera_moved` says the "
"gesture moved the camera, so earlier screenshots and pixels no longer match the view.\n"
"With target, the gesture is on a web page's element instead (a canvas such as the colour picker's spectrum, a "
"slider, a sortable or scrolled list): x/y, to and waypoints are logical pixels from its top left, a drag keeps the "
"pointer captured where the page asks for it, and a wheel scrolls what is under the pointer unless the page takes "
"it; page says what the gesture changed there, as for widget_click.",
"it; page says what the gesture changed there, as for `widget_click`.",
object_schema({{"action", enum_prop({"move", "down", "up", "click", "drag", "wheel"}, "Default click.")},
{"canvas", enum_prop(mouse_canvases, "Default current, the view shown. design takes x/y only.")},
{"at", target_schema},
@@ -1748,7 +1748,7 @@ void register_ui_tools(CommandCatalog& catalog)
{"modifiers", kModifiersSchema},
{"popup_item", kPopupItemSchema},
{"target", {{"type", json::array({"string", "object"})},
{"description", "A web page's element (its ref or a {web}/{css} locator) to gesture on instead of a 3D canvas."}}},
{"description", "A web page's element (its ref or a `{web}`/`{css}` locator) to gesture on instead of a 3D canvas."}}},
{"timeout_s", kPageTimeoutSchema}}),
[](const json& args, ToolContext& ctx) {
AutomationRuntime& runtime = ctx.runtime();
@@ -1802,14 +1802,14 @@ void register_ui_tools(CommandCatalog& catalog)
catalog.add(mutate_tool(
"gizmo_pick_file", L("Load or save the open gizmo's SVG or texture file"),
"Do what a file picker inside the open gizmo does, with a path instead of its dialog: svg_change loads another SVG "
"file into the SVG part being edited, svg_save_as writes that part's SVG to a new file (an existing one only with "
"overwrite), texture_import imports a height-map image into the texture library and puts it on Texture "
"Displacement's active layer. To add an SVG part, use object_add_svg with a path. Gizmos open with "
"widget_click {target: {gizmo: name}}, and their panels take widget_set_value / widget_click on the ImGui items widget_list lists.",
"Do what a file picker inside the open gizmo does, with a path instead of its dialog: `svg_change` loads another SVG "
"file into the SVG part being edited, `svg_save_as` writes that part's SVG to a new file (an existing one only with "
"overwrite), `texture_import` imports a height-map image into the texture library and puts it on Texture "
"Displacement's active layer. To add an SVG part, use `object_add_svg` with a path. Gizmos open with "
"`widget_click {target: {gizmo: name}}`, and their panels take `widget_set_value` / `widget_click` on the ImGui items `widget_list` lists.",
object_schema({{"action", enum_prop({"svg_change", "svg_save_as", "texture_import"}, "What to do.")},
{"path", prop("string", "Absolute path of the file to read or write.")},
{"overwrite", prop("boolean", "svg_save_as: replace an existing file.")}},
{"overwrite", prop("boolean", "`svg_save_as`: replace an existing file.")}},
{"action", "path"}),
[](const json& args, ToolContext& ctx) {
const std::string action = arg_string(args, "action");
@@ -1850,22 +1850,22 @@ void register_ui_tools(CommandCatalog& catalog)
catalog.add(recover_input_tool(
"dialog_answer", L("Answer a dialog"),
"Press a button of the topmost modal dialog: yes, no, ok, cancel, close, apply, a button's label, or a numeric id. "
"A disabled button (enabled: false) is refused, the dialog's message showing what it still needs, and so is one on "
"A disabled button (`enabled: false`) is refused, the dialog's message showing what it still needs, and so is one on "
"a page the dialog does not show, except a hidden cancel or close, which ends the dialog. On a dialog that is "
"neither native nor a web dialog, a standard name or id it has no button for ends it with that answer too, "
"without a handler running (pressed: false). The label of an option of a "
"without a handler running (`pressed: false`). The label of an option of a "
"selector made of buttons (Orca's radio groups, tab bars and multi-switches, shown as (*) / ( ) in the message) "
"selects that option and leaves the dialog open; set other radio buttons and switches with widget_click or widget_set_value "
"true, and notebook tabs with widget_click. "
"selects that option and leaves the dialog open; set other radio buttons and switches with `widget_click` or `widget_set_value` "
"true, and notebook tabs with `widget_click`. "
"dialog.title, text the dialog's title contains, makes sure which dialog that is; it must be the topmost. Reply: "
"dialog, button, pressed, and id, the wx id pressed or ended with, or web: true for a button on a web dialog's "
"page, with what the page did as widget_click reports it; closed: true when it closed, and dialogs, those still open. A "
"native message box (native: true) is pressed through "
"the OS, by one of the buttons app_state.dialogs lists for it; a file or folder picker can't be answered here, nor "
"any native dialog on macOS (its buttons list is empty): register dialog_auto_answer before opening them. A web "
"dialog, button, pressed, and id, the wx id pressed or ended with, or `web: true` for a button on a web dialog's "
"page, with what the page did as `widget_click` reports it; `closed: true` when it closed, and dialogs, those still open. A "
"native message box (`native: true`) is pressed through "
"the OS, by one of the buttons `app_state.dialogs` lists for it; a file or folder picker can't be answered here, nor "
"any native dialog on macOS (its buttons list is empty): register `dialog_auto_answer` before opening them. A web "
"dialog's buttons are on its page: a label is pressed there, waiting up to 3 s for it to show, so the page's own "
"handler runs. With no such page button, or a page busy for those 3 s, cancel and close end the dialog, and ok, yes, "
"no and apply are refused rather than skip the page's commit; page_buttons then lists the page's buttons.",
"no and apply are refused rather than skip the page's commit; `page_buttons` then lists the page's buttons.",
object_schema({{"button", prop("string", "Button to press.")},
{"dialog", {{"type", "object"},
{"properties", {{"title", prop("string", "Text the dialog's title contains (case-insensitive).")}}},
@@ -2029,15 +2029,15 @@ void register_ui_tools(CommandCatalog& catalog)
NativeCommand def = recover_input_tool(
"dialog_auto_answer", L("Answer dialogs automatically"),
"Answer modal dialogs automatically when their title or message matches a rule's regex (case-insensitive). "
"app_state.auto_answer_rules lists the rules in force. Called from a replay or script, the rules join those "
"`app_state.auto_answer_rules` lists the rules in force. Called from a replay or script, the rules join those "
"it set before and last until it ends, and a plugin's likewise until it unloads; an MCP client's replace the "
"ones MCP clients set before and last until the MCP server stops, and an empty list clears them. Reply: scope (run, plugin or session), rules (uses counts "
"a rule's answers) and answered_open_dialog. A native dialog "
"a rule's answers) and `answered_open_dialog`. A native dialog "
"returns the rule's button at once and never shows. A file or folder picker takes button ok with an absolute path "
"and returns it without showing; without a path a picker can only be cancelled, "
"and a multi-select picker takes no path. A wx dialog is answered as dialog_answer does. A matching dialog "
"and a multi-select picker takes no path. A wx dialog is answered as `dialog_answer` does. A matching dialog "
"already open is answered too "
"(answered_open_dialog), so a prompt that shows around the same time, such as the restore prompt after startup, "
"(`answered_open_dialog`), so a prompt that shows around the same time, such as the restore prompt after startup, "
"is caught either way. A web dialog is matched by its title: a button that names one of its shown wx buttons (by "
"label, standard name or id) is pressed as for a wx dialog, any other on its page once it shows there, for up to "
"10 s after the page loads; past that, cancel and close end the dialog and any other button gives up.",
@@ -2111,13 +2111,13 @@ void register_ui_tools(CommandCatalog& catalog)
NativeCommand eval = recover_input_tool(
"webview_run_javascript", L("Run JavaScript in a web view"),
"Evaluate JavaScript in one of OrcaSlicer's web views (Home, the device page, dialogs, plugin windows). Prefer "
"widget_list and the input tools (widget_click, widget_set_value, keyboard_press, mouse_gesture), which see and drive pages as they do widgets. The code runs in the target's page: "
"a web view's (kind webview in widget_list), or a page element's, with the element as `el`; without a target, in "
"`widget_list` and the input tools (`widget_click`, `widget_set_value`, `keyboard_press`, `mouse_gesture`), which see and drive pages as they do widgets. The code runs in the target's page: "
"a web view's (kind webview in `widget_list`), or a page element's, with the element as `el`; without a target, in "
"the topmost dialog's web view, else in the only shown one. While a modal dialog is open, only its pages run "
"code. Reply: result, the value of the last expression (JSON values come back parsed), and url; closed: true when "
"the code closed its dialog, navigated: true when it changed the page, dialogs when it opened another. Messages "
"code. Reply: result, the value of the last expression (JSON values come back parsed), and url; `closed: true` when "
"the code closed its dialog, `navigated: true` when it changed the page, dialogs when it opened another. Messages "
"the page posts to OrcaSlicer reach it once the code has returned. It runs through eval, which a page whose "
"Content-Security-Policy forbids it may refuse (widget_list and the input tools still work there).",
"Content-Security-Policy forbids it may refuse (`widget_list` and the input tools still work there).",
object_schema({{"code", prop("string", "JavaScript statements, run through eval: the last expression's value is the "
"result. No top-level return or await; a Promise or a DOM node comes back as {}.")},
{"target", kPageTargetSchema},
+44 -44
View File
@@ -600,19 +600,19 @@ void register_view_tools(CommandCatalog& catalog)
{
NativeCommand screenshot = inspect_tool(
"window_screenshot", L("Take a screenshot"),
"Capture what OrcaSlicer shows and return it as an image, downscaled to max_dim on the long edge (default 1280), "
"plus the full-size PNG written to save_path (or the session's output folder). target: \"main\" (the main "
"Capture what OrcaSlicer shows and return it as an image, downscaled to `max_dim` on the long edge (default 1280), "
"plus the full-size PNG written to `save_path` (or the session's output folder). `target: \"main\"` (the main "
"window), \"canvas\" (the visible 3D view exactly as rendered: scene, toolpaths, toolbars, ImGui panels; on the "
"Design tab its view), "
"\"dialog\" (the topmost modal dialog), or a ref: a window's from window_list (one that is not modal, say), or a "
"widget's from widget_list, cropped to that widget (a page element's ref captures its whole web view). The result "
"\"dialog\" (the topmost modal dialog), or a ref: a window's from `window_list` (one that is not modal, say), or a "
"widget's from `widget_list`, cropped to that widget (a page element's ref captures its whole web view). The result "
"says when parts may differ from the "
"screen (approximate). Point the view first with view_set.",
"screen (approximate). Point the view first with `view_set`.",
object_schema({{"target", {{"type", json::array({"string", "object"})},
{"description", "main (default), canvas, dialog, or a widget's ref or locator from widget_list."}}},
{"description", "main (default), canvas, dialog, or a widget's ref or locator from `widget_list`."}}},
{"max_dim", {{"type", "integer"}, {"minimum", 256}, {"maximum", 2000}, {"description", "Long edge of the returned image."}}},
{"save_path", prop("string", "Absolute .png path for the full-size image.")},
{"overwrite", prop("boolean", "Replace an existing save_path.")},
{"overwrite", prop("boolean", "Replace an existing `save_path`.")},
{"include_image", prop("boolean", "Return the image itself (default true); false returns only the path.")}}),
[](const json& args, ToolContext& ctx) {
AutomationRuntime& runtime = ctx.runtime();
@@ -760,16 +760,16 @@ void register_view_tools(CommandCatalog& catalog)
catalog.add(inspect_tool(
"plate_slice_stats", L("Get slice statistics"),
"What the Preview shows for a sliced plate. summary: plate_slice's, plus prepare and travel time and travel "
"What the Preview shows for a sliced plate. summary: `plate_slice`'s, plus prepare and travel time and travel "
"distance. features: seconds, share of the print time and grams per feature type (the Line Type legend), and "
"travel. layers: per layer (1-based, as view_set's layer) Z, height, seconds and grams, paged; layer_features adds "
"each feature type's seconds. objects: grams per object instance, with its object_list index when its name is "
"travel. layers: per layer (1-based, as `view_set`'s layer) Z, height, seconds and grams, paged; `layer_features` adds "
"each feature type's seconds. objects: grams per object instance, with its `object_list` index when its name is "
"unique. view, for the plate the Preview shows: view type, time mode, layer range, which legend rows are visible, "
"and each view type's colour range for what the legend shows. Times are normal-mode estimates. A G-code file "
"opened for viewing reads the same.",
object_schema({{"plate", {{"type", "integer"}, {"minimum", 0}, {"description", "Plate index; default the current plate."}}},
{"include", array_prop({{"type", "string"}, {"enum", json::array({"features", "layers", "layer_features", "objects", "view"})}},
"Parts besides the summary; default [\"features\", \"view\"].")},
"Parts besides the summary; default `[\"features\", \"view\"]`.")},
{"limit", {{"type", "integer"}, {"minimum", 1}, {"maximum", 1000}, {"description", "Layers per page (default 100)."}}},
{"offset", {{"type", "integer"}, {"minimum", 0}}}}),
[](const json& args, ToolContext& ctx) {
@@ -848,29 +848,29 @@ void register_view_tools(CommandCatalog& catalog)
"view_set", L("Set up the view"),
"Set up what the window shows, for screenshots and GUI work: the main tab, the 3D view (canvas: Prepare's, the "
"preview or the assemble view, which has its own gizmos), the camera of the 3D view shown (a named direction, the "
"default view, or fit to bed / objects / selection, then look_at, the point it looks at, an orbit to look from "
"default view, or fit to bed / objects / selection, then `look_at`, the point it looks at, an orbit to look from "
"between the named directions, and the zoom), the preview's color scheme (picked as in the legend's combo, which "
"shows every feature type again), legend rows, time estimate and layers (1-based, or up to a height). Only the given "
"fields change, but a preview field given without tab or canvas shows the Preview tab. On the Design tab the camera points its view (default is its Home view; no fit_bed; "
"sketch_normal looks straight at the open sketch), and with tab design, section, origin_planes, world_axes, origin and bed "
"set the Design view's switches. The reply echoes them; preview layers as [first, last, count] with z, the heights of "
"fields change, but a preview field given without tab or canvas shows the Preview tab. On the Design tab the camera points its view (default is its Home view; no `fit_bed`; "
"`sketch_normal` looks straight at the open sketch), and with tab design, section, `origin_planes`, `world_axes`, origin and bed "
"set the Design view's switches. The reply echoes them; preview layers as `[first, last, count]` with z, the heights of "
"first and last; with tab design, design: the section view and the four switches as they then are; with any camera "
"field, camera_state, the camera it leaves as app_state.camera gives it, and adjusted: [\"zoom\"] when the zoom "
"field, `camera_state`, the camera it leaves as `app_state.camera` gives it, and adjusted: [\"zoom\"] when the zoom "
"was held to its limits. tab takes the id of any other page of the window too, such as a plugin's. projection "
"sets the 3D camera's, layout default restores the default window layout, and layer_percent shows the Preview "
"at that share of the layer range, as Go to layer does. Outside the Design tab, from any tab: section {on} turns "
"sets the 3D camera's, layout default restores the default window layout, and `layer_percent` shows the Preview "
"at that share of the layer range, as Go to layer does. Outside the Design tab, from any tab: section `{on}` turns "
"the section view of Prepare and the Preview on or off; labels, overhangs, outline, wireframe, gridlines, axes and "
"navigator set the display switches of the View menu and of the 3D view's own menu; sidebar_collapsed and "
"sidebar_width set the sidebar of Prepare and the Preview; in the Preview, legend_collapsed folds the legend and "
"gcode_window shows the G-code window. Each is echoed as the app reads it back, and app_state's view gives them "
"navigator set the display switches of the View menu and of the 3D view's own menu; `sidebar_collapsed` and "
"`sidebar_width` set the sidebar of Prepare and the Preview; in the Preview, `legend_collapsed` folds the legend and "
"`gcode_window` shows the G-code window. Each is echoed as the app reads it back, and `app_state`'s view gives them "
"under these names. A pick of a view action runs the same code in place, so a camera action turns the Design "
"tab's camera too.",
object_schema({{"tab", prop("string", "Main window tab: " + tab_words + ", or the id of another page of the window "
"(monitor_web, the web Device page where the app shows one, or a plugin's page).")},
"(`monitor_web`, the web Device page where the app shows one, or a plugin's page).")},
{"canvas", enum_prop({"3d", "preview", "assemble"}, "3D view: Prepare's, the preview, or the assemble view (needs an object; leave it with 3d, as its Return button does).")},
{"camera", enum_prop({"iso", "top", "bottom", "front", "rear", "left", "right", "default", "fit_bed", "fit_objects", "fit_selection",
"sketch_normal"},
"Camera direction or fit; sketch_normal (Design tab) looks along the open sketch's normal, refused "
"Camera direction or fit; `sketch_normal` (Design tab) looks along the open sketch's normal, refused "
"with no sketch open.")},
{"section", {{"type", "object"},
{"properties", {{"on", {{"type", "boolean"}, {"description", "Cut the model, or show it whole."}}},
@@ -889,26 +889,26 @@ void register_view_tools(CommandCatalog& catalog)
{"origin", {{"type", "boolean"}, {"description", "Design tab: the Origin row's eye, the XY, XZ and YZ planes kept up "
"where a click picks one; off lets go of a picked plane."}}},
{"bed", {{"type", "boolean"}, {"description", "Design tab: the Bed row's eye, the printer bed drawn."}}},
{"look_at", array_prop({{"type", "number"}}, "[x, y, z] in mm: the point the camera looks at, in the 3D view's "
"world coordinates, as object_list gives positions; on the Design tab, "
"the Design view's, which the Design commands' world points use (describe_design's "
"modeling_origin is the sketch planes' origin). The camera moves "
{"look_at", array_prop({{"type", "number"}}, "`[x, y, z]` in mm: the point the camera looks at, in the 3D view's "
"world coordinates, as `object_list` gives positions; on the Design tab, "
"the Design view's, which the Design commands' world points use (`describe_design`'s "
"`modeling_origin` is the sketch planes' origin). The camera moves "
"parallel, keeping its direction and distance. After camera.")},
{"orbit", array_prop({{"type", "number"}}, "[yaw, pitch] in degrees: move the camera around what it looks at, "
{"orbit", array_prop({{"type", "number"}}, "`[yaw, pitch]` in degrees: move the camera around what it looks at, "
"yaw to its right and pitch up (negative looks from lower), after "
"camera and look_at. The same on every install, unlike a mouse drag.")},
"camera and `look_at`. The same on every install, unlike a mouse drag.")},
{"zoom", {{"type", "number"}, {"exclusiveMinimum", 0},
{"description", "Screenshot pixels per mm at look_at's depth, so everywhere in an orthographic view; "
{"description", "Screenshot pixels per mm at `look_at`'s depth, so everywhere in an orthographic view; "
"held to the camera's limits (at most 250, at least what the scene's size allows). Applied last."}}},
{"layer", {{"type", "integer"}, {"minimum", 1}, {"description", "Preview: show layers up to this one (1-based)."}}},
{"layer_range", array_prop({{"type", "integer"}}, "Preview: [first, last] layers, 1-based.")},
{"layer_range", array_prop({{"type", "integer"}}, "Preview: `[first, last]` layers, 1-based.")},
{"layer_z", {{"type", "number"}, {"minimum", 0}, {"description", "Preview: show layers up to the first whose top is at or above this height (mm), as the slider places a custom G-code."}}},
{"view_type", enum_prop(view_types, "Preview color scheme.")},
{"legend", {{"type", "object"}, {"additionalProperties", {{"type", "boolean"}}},
{"description", "Preview: show (true) or hide (false) legend rows: feature types by name as plate_slice_stats lists them "
"(\"Sparse infill\"), and travel, wipe, retract, unretract, seams, filament_changes, color_changes, "
"pauses, custom_gcode, in any case and with _ or a space between words. Hiding a row this "
"print lacks does nothing. Applied after view_type."}}},
{"description", "Preview: show (true) or hide (false) legend rows: feature types by name as `plate_slice_stats` lists them "
"(\"Sparse infill\"), and travel, wipe, retract, unretract, seams, `filament_changes`, `color_changes`, "
"pauses, `custom_gcode`, in any case and with _ or a space between words. Hiding a row this "
"print lacks does nothing. Applied after `view_type`."}}},
{"time_mode", enum_prop({"normal", "silent"}, "Preview: the time estimate the legend and layer times show; silent only when the print has its own.")},
{"layer_percent", {{"type", "number"}, {"minimum", 0}, {"maximum", 100},
{"description", "Preview: show the layers up to this share of the layer range, as Go to "
@@ -923,7 +923,7 @@ void register_view_tools(CommandCatalog& catalog)
{"minimum", 1},
{"description", "The sidebar's width in pixels, as a drag of its edge sets it, or "
"\"default\", its width in the default window layout. A sidebar "
"floating in a window of its own is sized with window_set."}}},
"floating in a window of its own is sized with `window_set`."}}},
{"legend_collapsed", prop("boolean", "Preview: fold the legend to its title row (true) or unfold it (false), "
"as its fold button does.")},
{"gcode_window", prop("boolean", "Preview: show (true) or hide (false) the G-code window, as View > Show "
@@ -935,7 +935,7 @@ void register_view_tools(CommandCatalog& catalog)
{"wireframe", prop("boolean", "The objects' wireframe, as the 3D view's own menu sets it.")},
{"gridlines", prop("boolean", "The plate's gridlines, as View > Show Gridlines sets them.")},
{"axes", prop("boolean", "The axes on the bed of Prepare and the Preview, as the 3D view's own menu sets "
"them; with tab design, world_axes is the Design view's.")},
"them; with tab design, `world_axes` is the Design view's.")},
{"navigator", prop("boolean", "The 3D navigator of Prepare and the Preview, as View > Show 3D Navigator "
"sets it.")}}),
[](const json& args, ToolContext& ctx) {
@@ -1358,15 +1358,15 @@ void register_view_tools(CommandCatalog& catalog)
"window_open", L("Open a window"),
"Open one of OrcaSlicer's windows or dialogs for a person, as its menu item does: preferences, the Preferences dialog, "
"with tab, and key on it, on that tab with that preference's control scrolled into view and focused (its controls are "
"named after their preference keys: preferences_get reads them and preferences_set writes those it does not refuse, "
"and widget_set_value {\"target\": {\"name\": key, \"within\": \"Preferences\"}} changes one through the "
"dialog); plugins, the Plugins window; action_replay, the "
"Action Replay window, where a person replays a replay file (agents run one with replay_run); preset_bundle, the preset "
"bundle manager; keyboard_shortcuts; setup_wizard; network_test; troubleshoot, the troubleshooting center; "
"tip_of_the_day; about. A modal one replies blocked_by_dialog.",
"named after their preference keys: `preferences_get` reads them and `preferences_set` writes those it does not refuse, "
"and `widget_set_value {\"target\": {\"name\": key, \"within\": \"Preferences\"}}` changes one through the "
"dialog); plugins, the Plugins window; `action_replay`, the "
"Action Replay window, where a person replays a replay file (agents run one with `replay_run`); `preset_bundle`, the preset "
"bundle manager; `keyboard_shortcuts`; `setup_wizard`; `network_test`; troubleshoot, the troubleshooting center; "
"`tip_of_the_day`; about. A modal one replies `blocked_by_dialog`.",
object_schema({{"window", enum_prop(windows, "The window.")},
{"tab", enum_prop(MenuItems::preferences_tabs(), "preferences: the tab to show.")},
{"key", prop("string", "preferences, with tab: a preference on that tab, e.g. auto_arrange on behaviour: "
{"key", prop("string", "preferences, with tab: a preference on that tab, e.g. `auto_arrange` on behaviour: "
"its control is scrolled into view and focused.")}},
{"window"}),
std::move(window_actions), [](const json& args) {
+35
View File
@@ -1,6 +1,8 @@
#include <catch2/catch_message.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include <catch2/matchers/catch_matchers.hpp>
#include <catch2/matchers/catch_matchers_string.hpp>
#include "automation_test_utils.hpp"
@@ -37,6 +39,7 @@
using namespace Slic3r::GUI;
using namespace Slic3r::GUI::Mcp;
using nlohmann::json;
using Catch::Matchers::ContainsSubstring;
using Slic3r::GUI::CommandCatalog;
using Slic3r::GUI::CommandFn;
using Slic3r::GUI::NativeCommand;
@@ -386,12 +389,44 @@ TEST_CASE("blocked_by_dialog is reported after the soft budget when the probe se
const ToolResult envelope = h.call("open_modal");
CHECK(envelope.data["status"] == "blocked_by_dialog");
CHECK(envelope.data["dialogs"][0]["title"] == "Unsaved changes");
// A command without silent is told to give the dialog's answer as an argument next time.
CHECK_THAT(envelope.data["note"].get<std::string>(), ContainsSubstring("Next time, give the dialog's answer as an argument"));
release = true;
auto result = h.jobs.wait(envelope.data["job"], 3000ms);
REQUIRE(result.has_value());
CHECK(result->data["closed"] == true);
}
TEST_CASE("a blocked call of a command that takes silent is told to pass it next time", "[Mcp]")
{
Harness h;
std::atomic<bool> release{false};
NativeCommand asks = tool("asks", GuardClass::Mutate, [&](const json&, ToolContext& ctx) {
ctx.run_ui([&] {
h.modal_loop(release, json::array({{{"title", "Primitive size"}}}));
return json();
});
return ToolResult::ok({{"closed", true}});
});
asks.input_schema = {{"type", "object"}, {"properties", {{"silent", {{"type", "boolean"}, {"enum", {true}}}}}}};
h.registry.add(std::move(asks));
h.start();
const ToolResult asked = h.call("asks");
REQUIRE(asked.data["status"] == "blocked_by_dialog");
CHECK_THAT(asked.data["note"].get<std::string>(), ContainsSubstring("Next time, `silent: true` runs it without asking."));
release = true;
REQUIRE(h.jobs.wait(asked.data["job"], 3000ms).has_value());
// A call that gave silent and still asks is of a command whose dialog always opens: no advice.
release = false;
const ToolResult always = h.call("asks", {{"silent", true}});
REQUIRE(always.data["status"] == "blocked_by_dialog");
CHECK(always.data["note"].get<std::string>().find("Next time") == std::string::npos);
release = true;
REQUIRE(h.jobs.wait(always.data["job"], 3000ms).has_value());
}
TEST_CASE("a dialog whose answer was queued as it opened does not hold the call", "[Mcp]")
{
Harness h;
File diff suppressed because it is too large. Load diff
+9 -4
View File
@@ -1830,12 +1830,13 @@ TEST_CASE("the tool_list description names every Design command under its headin
CHECK(commands_named == std::set<std::string>{});
const std::string index = told.substr(plain.size());
CHECK_THAT(index, ContainsSubstring("CAD"));
CHECK_THAT(index, ContainsSubstring("tool_describe {tool} gives one's manual"));
CHECK_THAT(index, ContainsSubstring("`tool_describe {tool}` gives one's manual"));
// A command with silent does what its menu item does when it is given no arguments.
CHECK_THAT(index, ContainsSubstring("silent does what its menu item does when called with no arguments, unless silent is true"));
CHECK_THAT(index,
ContainsSubstring("`silent` does what its menu item does when called with no arguments, unless `silent` is true"));
// Each heading starts a sentence once, in the design's order, and its names follow its colon to the full stop,
// apart by ", ", in the table's order.
// apart by ", ", in the table's order, each marked as code.
std::size_t at = 0;
std::size_t named = 0;
for (const char* heading : GUI::kDesignSections) {
@@ -1852,7 +1853,11 @@ TEST_CASE("the tool_list description names every Design command under its headin
std::vector<std::string> names;
for (std::size_t from = colon + 2; from < stop;) {
const std::size_t comma = std::min(index.find(", ", from), stop);
names.push_back(index.substr(from, comma - from));
const std::string marked = index.substr(from, comma - from);
REQUIRE(marked.size() > 2);
CHECK(marked.front() == '`');
CHECK(marked.back() == '`');
names.push_back(marked.substr(1, marked.size() - 2));
from = comma + 2;
}
std::vector<std::string> in_table;
+2 -1
View File
@@ -1813,10 +1813,11 @@ TEST_CASE("a gizmo command's acting arguments are schema properties its descript
CHECK(command->description.find("Acts from arguments:") == std::string::npos);
continue;
}
// Each marked as code, as descriptions mark argument names.
std::string names;
for (const std::string& name : acting) {
CHECK(command->input_schema.at("properties").contains(name));
names += (names.empty() ? "" : ", ") + name;
names += (names.empty() ? "`" : ", `") + name + "`";
}
CHECK_THAT(command->description, ContainsSubstring("Acts from arguments: " + names + "."));
}
+60 -46
View File
@@ -551,17 +551,20 @@ TEST_CASE("a tool of the old vocabulary is no command", "[Mcp]")
const char* first_sentence;
};
static const Renamed renamed[] = {
{"call_tool", "tool_call", "Call any command by name with its arguments: a tool, or one the tool list does not show, a menu item "
"that takes no arguments, a Design tab command or an operation a plugin offers (tool_list lists them; "
"tool_describe gives any command's manual)."},
{"call_tool", "tool_call",
"Call any command by name with its arguments: a tool, or one the tool list does not show, a menu "
"item that takes no arguments, a Design tab command or an operation a plugin offers (`tool_list` "
"lists them; `tool_describe` gives any command's manual)."},
{"generate_calibration_test", "calibration_generate_test",
"Generate a Calibration menu test as its dialog's OK does: a new project named after the test with the test model, and the "
"process, filament and printer presets changed as the test needs (presets_changed)."},
"Generate a Calibration menu test as its dialog's OK does: a new project named after the test with "
"the test model, and the process, filament and printer presets changed as the test needs "
"(`presets_changed`)."},
{"export", "project_export", "Write the project to a file without a dialog."},
{"list_presets", "preset_list",
"Printer, process or filament presets, each with its name, alias (the name its selector shows, when another), system, user, "
"project (kept inside the project), inherits, selected (and modified), compatible: false or installed: false when so, and "
"vendor; a filament its filament_type and the slots using it (filament_slots), a printer its printer_model and nozzle."},
"Printer, process or filament presets, each with its name, alias (the name its selector shows, when "
"another), system, user, project (kept inside the project), inherits, selected (and modified), "
"`compatible: false` or `installed: false` when so, and vendor; a filament its `filament_type` and "
"the slots using it (`filament_slots`), a printer its `printer_model` and nozzle."},
{"select_preset", "preset_select", "Select a printer, process or filament preset by the name its selector shows (or its "
"internal name), as a person would."},
{"save_preset", "preset_save", "Save the printer, process or filament preset being edited, with its unsaved changes, as a preset "
@@ -569,9 +572,11 @@ TEST_CASE("a tool of the old vocabulary is no command", "[Mcp]")
{"delete_preset", "preset_delete", "Delete a user preset or one inside the project, its file and its cloud copy, as the tab's "
"Delete does, without asking."},
{"list_plates", "plate_list",
"Plates with name, locked, current, objects (how many are on it; object_list lists them), and the settings they print with: "
"curr_bed_type, print_sequence, spiral_mode, first_layer_print_sequence and other_layers_print_sequence (null: Auto), with "
"several extruders filament_map_mode and filament_map; overrides lists those the plate sets itself (plate_set_settings)."},
"Plates with name, locked, current, objects (how many are on it; `object_list` lists them), and the "
"settings they print with: `curr_bed_type`, `print_sequence`, `spiral_mode`, "
"`first_layer_print_sequence` and `other_layers_print_sequence` (null: Auto), with several extruders "
"`filament_map_mode` and `filament_map`; overrides lists those the plate sets itself "
"(`plate_set_settings`)."},
{"list_objects", "object_list", "The project as the Objects panel lists it."},
{"transform", "object_transform", "Change one instance's placement, or one part's with part."},
{"add_part", "part_add", "Add a part, negative part, modifier, support blocker or enforcer, or precise seam to an object, as its "
@@ -581,32 +586,37 @@ TEST_CASE("a tool of the old vocabulary is no command", "[Mcp]")
{"slice", "plate_slice", "Slice the current plate, all plates, or one plate by index, the way the toolbar's Slice button does, "
"and wait for the result (or reply with a job id when it takes longer than the reply budget)."},
{"set_height_ranges", "object_set_height_ranges",
"Replace an object's height range modifiers (Height Range Modifier in the object list): Z ranges in mm, each printed with its "
"own layer_height, filament and process settings, which settings_get and settings_set read and write with the target "
"height_range."},
"Replace an object's height range modifiers (Height Range Modifier in the object list): Z ranges in "
"mm, each printed with its own `layer_height`, filament and process settings, which `settings_get` "
"and `settings_set` read and write with the target `height_range`."},
{"set_variable_layer_height", "object_set_variable_layer_height",
"Run the Variable layer height panel's Adaptive, Smooth or Reset on an object, without opening the panel: adaptive computes "
"layer heights from the object's shape (inside a height range, the range's layer_height), smooth smooths its profile (or "
"the one its height ranges give), reset goes back to its layer height and ranges."},
"Run the Variable layer height panel's Adaptive, Smooth or Reset on an object, without opening the "
"panel: adaptive computes layer heights from the object's shape (inside a height range, the range's "
"`layer_height`), smooth smooths its profile (or the one its height ranges give), reset goes back to "
"its layer height and ranges."},
{"set_custom_gcode_at_layer", "plate_set_custom_gcode",
"Add or remove pauses, custom G-code, custom templates and filament changes at the start of a layer, as the Preview layer "
"slider's menu does; they are saved per plate in the project."},
{"get_slice_stats", "plate_slice_stats", "What the Preview shows for a sliced plate."},
{"get_app_state", "app_state", "Snapshot of OrcaSlicer."},
{"wait", "app_wait", "Block until a condition holds or timeout_s passes (max 50)."},
{"wait", "app_wait",
"Block until a condition holds or `timeout_s` passes (max 50)."},
{"get_log", "app_log", "The last lines of OrcaSlicer's current log file, optionally only those at or above a level."},
{"cancel_job", "job_cancel", "Stop the running operation: a slice or G-code export, as the slicing progress's cancel button "
"does, or a background job an MCP call started (an arrange, orient or fill bed)."},
{"run_replay", "replay_run", "Replay a list of tool calls in order and report each step: {orca_replay_version:\"0.2.0\", name, "
"vars, steps:[{tool, args, expect, optional, await, save_as, timeout_s}]}, JSON with comments."},
{"run_replay", "replay_run",
"Replay a list of tool calls in order and report each step: `{\"orca_replay_version\": \"0.2.0\", "
"name, vars, steps: [{tool, args, expect, optional, await, save_as, timeout_s}]}`, JSON with "
"comments."},
{"export_replay", "replay_export",
"Turn the calls this session made into a replay that replay_run runs: mutating calls, app_wait, window_screenshot and the "
"recording tools, in order, with refs replaced by locators, job replies replayed with await:false, and window_screenshot "
"and recording paths moved under ${out_dir}."},
"Turn the calls this session made into a replay that `replay_run` runs: mutating calls, `app_wait`, "
"`window_screenshot` and the recording tools, in order, with refs replaced by locators, job replies "
"replayed with await:false, and `window_screenshot` and recording paths moved under `${out_dir}`."},
{"run_script", "script_run",
"Run Python code inside OrcaSlicer as its main program (__name__ == \"__main__\") against orca.host, the whole plugin API "
"(script_list_api lists it): read objects, meshes and settings, compute, use orca.host.ui and the preset API, and call "
"these same tools, with their guards and undo, through orca.host.tools.call(name, args)."},
"Run Python code inside OrcaSlicer as its main program (__name__ == \"__main__\") against "
"`orca.host`, the whole plugin API (`script_list_api` lists it): read objects, meshes and settings, "
"compute, use `orca.host.ui` and the preset API, and call these same tools, with their guards and "
"undo, through `orca.host.tools.call`(name, args)."},
{"answer_dialog", "dialog_answer", "Press a button of the topmost modal dialog: yes, no, ok, cancel, close, apply, a button's "
"label, or a numeric id."},
{"auto_answer_dialogs", "dialog_auto_answer", "Answer modal dialogs automatically when their title or message matches a rule's "
@@ -614,30 +624,33 @@ TEST_CASE("a tool of the old vocabulary is no command", "[Mcp]")
{"select_objects", "object_select", "Select objects, instances or parts in the 3D view (the assemble view while it is shown, "
"else Prepare, switching to it), as clicking them would."},
{"screenshot", "window_screenshot",
"Capture what OrcaSlicer shows and return it as an image, downscaled to max_dim on the long edge (default 1280), plus the "
"full-size PNG written to save_path (or the session's output folder)."},
"Capture what OrcaSlicer shows and return it as an image, downscaled to `max_dim` on the long edge "
"(default 1280), plus the full-size PNG written to `save_path` (or the session's output folder)."},
{"set_view", "view_set",
"Set up what the window shows, for screenshots and GUI work: the main tab, the 3D view (canvas: Prepare's, the preview or the "
"assemble view, which has its own gizmos), the camera of the 3D view shown (a named direction, the default view, or fit to "
"bed / objects / selection, then look_at, the point it looks at, an orbit to look from between the named directions, and the "
"zoom), the preview's color scheme (picked as in the legend's combo, which shows every feature type again), legend rows, "
"time estimate and layers (1-based, or up to a height)."},
"Set up what the window shows, for screenshots and GUI work: the main tab, the 3D view (canvas: "
"Prepare's, the preview or the assemble view, which has its own gizmos), the camera of the 3D view "
"shown (a named direction, the default view, or fit to bed / objects / selection, then `look_at`, "
"the point it looks at, an orbit to look from between the named directions, and the zoom), the "
"preview's color scheme (picked as in the legend's combo, which shows every feature type again), "
"legend rows, time estimate and layers (1-based, or up to a height)."},
{"encode_recording", "recording_encode", "Encode a recording into an H.265 (or H.264) MP4 with the system ffmpeg (ORCA_FFMPEG, "
"else ffmpeg on PATH; it needs libx265 or libx264), keeping its timing."},
{"run_action", "action_run", "Run one action by the id action_list returned (orca_command:view_front:orca, or the name "
"inside it, view_front), with args, the command's arguments, when it takes some (its "
"input_schema)."},
{"run_action", "action_run",
"Run one action by the id `action_list` returned (`orca_command:view_front:orca`, or the name inside "
"it, `view_front`), with `args`, the command's arguments, when it takes some (its `input_schema`)."},
{"list_windows", "window_list",
"List OrcaSlicer's open windows: the main window, then the windows that don't block the app (Plugins, an object's settings, "
"a dock panel floating on its own), then the modal dialogs in the order they opened, the topmost last."},
{"set_window", "window_set", "Size, move, maximize, minimize or raise a window: the main window (default), the topmost modal "
"dialog, or one window_list lists, also while a modal dialog is open."},
{"set_window", "window_set",
"Size, move, maximize, minimize or raise a window: the main window (default), the topmost modal "
"dialog, or one `window_list` lists, also while a modal dialog is open."},
{"list_widgets", "widget_list",
"Describe what is on screen as an indented tree, one element per line with a ref to pass to widget_click, widget_set_value, "
"keyboard_press and webview_run_javascript (a page element's to mouse_gesture too): the widgets of every shown window, the "
"rows of lists, trees and tables, each shown popup after the window it opened from, the main menus, the 3D canvas's "
"toolbar items and gizmos, each ImGui panel drawn in the last frame with its items and text, and the elements of each shown "
"web page (dialogs, the setup wizard, sign-in, plugin windows) under its web view."},
"Describe what is on screen as an indented tree, one element per line with a ref to pass to "
"`widget_click`, `widget_set_value`, `keyboard_press` and `webview_run_javascript` (a page element's "
"to `mouse_gesture` too): the widgets of every shown window, the rows of lists, trees and tables, "
"each shown popup after the window it opened from, the main menus, the 3D canvas's toolbar items and "
"gizmos, each ImGui panel drawn in the last frame with its items and text, and the elements of each "
"shown web page (dialogs, the setup wizard, sign-in, plugin windows) under its web view."},
{"click", "widget_click", "Click a GUI element as a person would."},
{"set_widget_value", "widget_set_value", "Set a widget's value and send the events a person's edit would."},
{"press_keys", "keyboard_press",
@@ -645,9 +658,10 @@ TEST_CASE("a tool of the old vocabulary is no command", "[Mcp]")
"target or, without one, to the focused window (the topmost dialog while one is open, the shown 3D view when nothing has "
"focus)."},
{"pick_gizmo_file", "gizmo_pick_file",
"Do what a file picker inside the open gizmo does, with a path instead of its dialog: svg_change loads another SVG file into "
"the SVG part being edited, svg_save_as writes that part's SVG to a new file (an existing one only with overwrite), "
"texture_import imports a height-map image into the texture library and puts it on Texture Displacement's active layer."},
"Do what a file picker inside the open gizmo does, with a path instead of its dialog: `svg_change` "
"loads another SVG file into the SVG part being edited, `svg_save_as` writes that part's SVG to a "
"new file (an existing one only with overwrite), `texture_import` imports a height-map image into "
"the texture library and puts it on Texture Displacement's active layer."},
{"run_javascript", "webview_run_javascript", "Evaluate JavaScript in one of OrcaSlicer's web views (Home, the device page, "
"dialogs, plugin windows)."},
};