mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-24 03:12:07 +00:00
docs(automation): add view.select client wrapper, example usage, and docs
This commit is contained in:
@@ -42,9 +42,10 @@ def main() -> int:
|
||||
print("ERROR: automation server did not start", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
# Load the model into the already-running instance, then wait until the
|
||||
# project reports loaded. file.open is synchronous, so project_loaded is
|
||||
# already true on return; the wait is a belt-and-suspenders guard.
|
||||
# Switch to the Prepare (3D editor) view first, then load the model into the
|
||||
# already-running instance. file.open is synchronous, so project_loaded is
|
||||
# already true on return; the wait below is a belt-and-suspenders guard.
|
||||
orca.select_view("prepare")
|
||||
orca.open([args.model])
|
||||
deadline = time.time() + 30
|
||||
while time.time() < deadline:
|
||||
|
||||
@@ -91,6 +91,15 @@ class OrcaClient:
|
||||
paths = [paths]
|
||||
return self._call("file.open", {"paths": list(paths)})
|
||||
|
||||
def select_view(self, view) -> dict:
|
||||
"""Switch the main window to a top-level view/tab by name.
|
||||
|
||||
`view` is one of: "home", "prepare", "preview", "device",
|
||||
"multi_device", "project", "calibration". Returns
|
||||
{"ok": True, "view": <name>, "index": <int>}. Raises OrcaError 1001 if the
|
||||
view name is unknown or not available in the current layout."""
|
||||
return self._call("view.select", {"view": view})
|
||||
|
||||
def wait_for(self, target: dict, state: str = "visible",
|
||||
value: Optional[str] = None, timeout_ms: int = 5000,
|
||||
poll_ms: int = 100) -> dict:
|
||||
|
||||
Reference in New Issue
Block a user