altium monkey v2026.11.26 · gobblerito
On This Page (4)

Examples Showcase / hello_schdoc

Create a SchDoc hello world

Generate a SchDoc programmatically, place text, and insert a monkey image.

schdochello-worldgenerationimageschematic

Create a schematic from scratch, place a text label, and embed a local monkey image.

This example is intentionally small. It is meant to show the public object-creation API, not internal record-plumbing.

What It Shows

  1. AltiumSchDoc() for a fresh schematic document
  2. make_sch_text_string(...)
  3. make_sch_embedded_image(...)
  4. AltiumSchDoc.add_object(...)
  5. AltiumSchDoc.save(...)

Run

From the package root:

powershell
uv run python examples\hello_schdoc\hello_schdoc.py

Output

The script writes:

text
examples/hello_schdoc/output/hello_schdoc.SchDoc

The sample-specific image asset lives at:

text
examples/hello_schdoc/assets/monkey.png

Source Code

examples/hello_schdoc/hello_schdoc.py
from pathlib import Path

from altium_monkey import (
    AltiumSchDoc,
    ColorValue,
    SchFontSpec,
    SchPointMils,
    SchRectMils,
    make_sch_embedded_image,
    make_sch_text_string,
)

SAMPLE_DIR = Path(__file__).resolve().parent
ASSET_PATH = SAMPLE_DIR / "assets" / "monkey.png"
OUTPUT_PATH = SAMPLE_DIR / "output" / "hello_schdoc.SchDoc"


def build_schdoc(output_path: Path = OUTPUT_PATH) -> Path:
    output_path.parent.mkdir(parents=True, exist_ok=True)

    schdoc = AltiumSchDoc()
    schdoc.add_object(
        make_sch_text_string(
            location_mils=SchPointMils.from_mils(1000, 1000),
            text="altium-monkey wuz here",
            font=SchFontSpec(name="Arial", size=18, bold=True),
            color=ColorValue.from_hex("#000000"),
        )
    )
    schdoc.add_object(
        make_sch_embedded_image(
            bounds_mils=SchRectMils.from_corners_mils(1000, 1200, 1800, 2000),
            source_path=ASSET_PATH,
            filename="monkey.png",
            keep_aspect=True,
        )
    )
    schdoc.save(output_path)
    return output_path


def main() -> None:
    output_path = build_schdoc()
    print(f"Wrote {output_path}")


if __name__ == "__main__":
    main()
altium-monkey v2026.11.26 · gobblerito·Docs updated 2026.11.29 17:55 UTC (0665053)