fix(task-18): the COM plot is foreground, by layout name, and confirmed on disk; plot_style_list reads PrinterStyleSheetPath
Three review findings against SECTION 19 on the live engine, each measured on AutoCAD 2026 in a scratch document with the operator's BACKGROUNDPLOT=2: - plot_style_list read Preferences.Files.PrintStyleSheetPath; the ActiveX member is PrinterStyleSheetPath, so the AttributeError was swallowed and every row came back installed=None. Renamed in the backend, the server docstring and the test fake (which faked the same wrong name). Live: 13 rows, all 9 catalogue ctb files installed, four .stb files as installed. - ComBackend.drawing_export_pdf returned ok before any file existed under background plotting, so batch_plot died on path.stat() with an unhandled FileNotFoundError and a later foreground plot raised E_FAIL. The export now sets BACKGROUNDPLOT=0 around PlotToFile (restored after), honours the method's bool and reports ok only with the file on disk (bytes included). batch_plot turns a backend RuntimeError or a phantom ok into a per-row ok:false, keeping the rows already plotted. - With a sheet current, the Model row was that sheet plotted again: the COM export switched tabs only when a layout was named. layout=None now makes Model current (restoring the tab), and batch_plot names every layout, Model included, so both engines plot the tab the row is labelled with. Live: Model row /Title (Model) at 210x297 beside the A3 sheet, the active tab and BACKGROUNDPLOT restored. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FKFStjEFzpGyLq5bMpWxTd
This commit is contained in:
co-authored by
Claude Opus 5
parent
f25421709f
commit
f6951e2597
@@ -36,7 +36,10 @@ async def batch_plot(
|
||||
"""Plot layouts to PDF and read each sheet size back from the file.
|
||||
|
||||
``layouts=None`` plots every paper-space layout; ``Model`` is plotted only
|
||||
when named. Refuses (``ValueError``, before any PDF is written): an empty
|
||||
when named, and is passed to the engine by name so the model row is model
|
||||
space whichever tab is current. A sheet the engine cannot plot, or reports
|
||||
plotted without a file, is a per-row ``ok: False`` with its ``error``; the
|
||||
rows before it stay. Refuses (``ValueError``, before any PDF is written): an empty
|
||||
list, a layout that does not exist, a pattern with a path separator, and
|
||||
a pattern without ``{layout}`` when more than one sheet would be written.
|
||||
The output folder is created, then every output path goes through
|
||||
@@ -95,12 +98,31 @@ async def batch_plot(
|
||||
sheets: list[dict] = []
|
||||
for name, path in planned:
|
||||
is_model = name.lower() == "model"
|
||||
result = await backend.drawing_export_pdf(str(path), layout=None if is_model else name)
|
||||
# The layout is always named — "Model" included — so the engine plots
|
||||
# the tab this row is labelled with, never the one that happens to be
|
||||
# current. A plot that fails inside the engine (COM raises RuntimeError
|
||||
# for an AutoCAD error) or that reports ok without leaving a file is a
|
||||
# failed row, not a lost batch: the sheets already plotted are kept.
|
||||
try:
|
||||
result = await backend.drawing_export_pdf(str(path), layout=name)
|
||||
except RuntimeError as exc:
|
||||
sheets.append({"layout": name, "ok": False, "path": str(path), "error": str(exc)})
|
||||
continue
|
||||
if not result.get("ok", False):
|
||||
sheets.append(
|
||||
{"layout": name, "ok": False, "path": str(path), "error": result.get("error")}
|
||||
)
|
||||
continue
|
||||
if not path.is_file():
|
||||
sheets.append(
|
||||
{
|
||||
"layout": name,
|
||||
"ok": False,
|
||||
"path": str(path),
|
||||
"error": "the engine reported the plot ok but no file was written",
|
||||
}
|
||||
)
|
||||
continue
|
||||
row = {"layout": name, "ok": True, "path": str(path), "bytes": path.stat().st_size}
|
||||
try:
|
||||
width, height = read_mediabox(str(path))
|
||||
|
||||
Reference in New Issue
Block a user