proj_close
Closes a PCB project, optionally saving modified documents or discarding unsaved edits, and handles save prompts so the editor bridge does not block.
Instructions
Close a project, saving its documents or discarding their edits.
save=True (default) writes this project's modified documents,
then closes it. save=False closes it without saving.
WITHOUT SAVING, TWO LAYERS KEEP THE BRIDGE FROM WEDGING. A close with a modified member raises Altium's save prompt inside the polling loop, where the bridge cannot answer it. MEASURED on AD 26.10.1.6: after an edit IServerDocument.Modified reads False while the tab shows the sheet modified, so nothing gated on that read works.
First, the handler clears the modified flag on every loaded member without reading it. MEASURED on a local scratch project: the close then raised no prompt and the file on disk was byte-identical.
Second, if a prompt appears anyway, this answers it through UI Automation: "Save None", then "OK" once the dialog has retitled to "Confirm Not Saving", which is what shows the decisions changed. Pressing OK before that would save. The sequence was measured by hand; this tool running it has not run live.
ALTIUM CLOSES THE FOCUSED PROJECT. MEASURED: a close naming a
project with no loaded document, while another project's board was
focused, closed that other project first. So the handler makes the
named project focused by showing one of its loaded documents, and
refuses, changing nothing, when it cannot. Every attempt compares
the open projects before and after: if anything else closed, it
stops without retrying and returns those paths as
closed_instead, with success false.
IT ANSWERS ONLY FOR THIS PROJECT. It records the project's member
paths before closing and reads every path the prompt lists. If any
listed document is outside the project it presses nothing and
returns them, because answering would discard work in a project
nobody named. It also presses nothing when membership cannot be
established: no project_path, or a deployed script that
reports member file names rather than paths.
A document shared with another open project is a member of both,
so its unsaved edits are discarded here too. save=True prompts
are never answered for you.
IF A PROMPT IS LEFT OPEN, answer it with app_invoke_element
(Save None, then OK) or app_press_dialog_button. Both
work while the bridge is blocked, because they go through Win32
rather than through the loop.
Args:
project_path: project to close. Omit for the focused project;
save=False then leaves any prompt for a human.
save: write modified documents first (True), or discard their
unsaved edits (False).
Returns:
success and closed, checked by looking the project up
again, and project_path. When a prompt was answered,
prompts_answered and discarded, the paths it listed.
When one was left, prompt and reason: the bridge stays
blocked until it is answered. Without a prompt, discarded
lists the loaded members closed without saving and
attempts how many closes it took. The modified flag cannot
be read reliably, so a path in discarded is not proof that
document had edits.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| save | No | ||
| project_path | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||