CLI command design

schdoc

Authors schematic documents through generated MCO operations.

Purpose

schdoc provides a small public authoring surface for Altium .SchDoc files. The command compiles to MCO so schematic creation uses the same document-session, dry-run, and reporting behavior as generated workflows.

Usage

altium-cruncher schdoc create
altium-cruncher schdoc create schdoc_create.jsonc
altium-cruncher schdoc create generated.SchDoc
altium-cruncher schdoc create generated.SchDoc --sheet-style D --json
altium-cruncher schdoc create generated.SchDoc --template titleblock.SchDot --apply-template-visual-sheet-settings
altium-cruncher schdoc create generated.SchDoc --custom-width-mils 34000 --custom-height-mils 22000

Arguments

ArgumentContract
createWith no target, writes schdoc_create.jsonc when no config exists. A later no-target run loads that config and creates the schematic document.
create config.jsoncLoads or initializes a SchDoc create config using schema altium_cruncher.schdoc.create.config.a0.
create fileLegacy direct mode. Destination .SchDoc. Paths are passed into generated MCO as file.
--sheet-styleAltium SheetStyle enum name or native integer. The default is D.
--templateOptional .SchDot template applied by the underlying Altium Monkey API.
--apply-template-visual-sheet-settingsWhen a template is used, also copies supported visual sheet settings.
--custom-width-mils, --custom-height-milsCustom sheet size in mils. Both values must be supplied together.
--emit-mco, --force, --dry-run, --json, --json-outputFollow the shared MCO command semantics for operation emission, overwrite, non-mutating planning, stdout JSON, and sidecar JSON report output.

Config Shape

Config structure, defaults and field help are authored in TypeSpec and validated on file loading. See the creation config contract guide for generated Python/browser codecs and compatibility details.

The A0 config is the same child object shape used by prjpcb.schematics[], with a top-level schema field. It contains file, optional sheet_style, optional template, optional apply_template_visual_sheet_settings, and optional custom_sheet_mils.

MCO Shape

schdoc create compiles to one schdoc.create operation. The operation accepts file, optional sheet_style, optional template, optional apply_template_visual_sheet_settings, optional custom_sheet_mils, and overwrite.

Output

The first config-first run writes the sample JSONC config only; the next run uses that config to write the requested .SchDoc unless --dry-run is used. Human output is the standard MCO execution summary. In --json mode, lower-level save progress is redirected to stderr so stdout is only the execution report JSON.

Tests

Coverage lives in tests/test_mco.py and tests/test_document_create_commands.py. It verifies default D-size creation, command JSON output, and reparsing the generated SchDoc through Altium Monkey.