AltiumSchDoc is the public container for schematic documents. It is the most
complete document object model in the current release.
Use it when you need to:
- create or modify
.SchDocfiles - add schematic primitives, ports, notes, templates, and images
- insert components from
.SchLib - iterate and normalize existing schematic objects
- render schematic pages to SVG
AltiumSchDoc owns a single ObjectCollection. Typed properties such as
schdoc.notes, schdoc.ports, schdoc.net_labels, schdoc.components,
schdoc.sheet_symbols, and schdoc.harness_connectors are live filtered views
over that collection.
Use filtered views for query and traversal. Do not append to filtered views. Change membership through the document:
note = make_sch_note(...)
schdoc.add_object(note)
for note in schdoc.notes:
note.font = SchFontSpec(name="Courier New", size=10)
schdoc.remove_object(note)
schdoc.save("updated.SchDoc")The document resolves IndexInSheet, owner indexes, font indexes, and related
serialization details when objects are added, removed, and saved.
Public SchDoc authoring APIs use mils. Prefer SchPointMils, SchRectMils,
SchFontSpec, ColorValue, and public enums instead of raw integer fields.
Low-level record fields may expose native Altium storage units. Use those fields only when preserving parsed data or when no high-level property exists yet.
Some schematic records are invalid as top-level objects. Add them through their owner object so ownership and indexes stay valid.
Harness entries and harness type labels belong to harness connectors.
Sheet entries, sheet-name labels, and file-name labels belong to sheet symbols.
Component pins, designators, parameters, and implementation records belong to components.
Use schdoc.add_component_from_library(...) for normal component insertion from
SchLib.
Use clear_template(), apply_template(...), and extract_template(...) for
schematic title blocks and border graphics stored as Altium .SchDot
templates.
By default, apply_template(...) applies template-owned drawing objects,
embedded images, fonts, missing template parameters, and template metadata. It
does not change the target sheet size or page setup unless requested.
If the .SchDot should also control the target page setup, pass
apply_visual_sheet_settings=True:
schdoc.apply_template(
"title_block.SchDot",
template_filename="title_block.SchDot",
apply_visual_sheet_settings=True,
)That option copies visual sheet context such as sheet style, custom sheet dimensions, border and reference-zone settings, display unit, grid settings, sheet colors, sheet-number spacing, and the sheet system font. It does not copy template identity, vault/release GUIDs, sheet number, or project/page parameters.
AltiumSchDoc preserves embedded IMAGE payloads in the schematic Storage
stream. When Altium stores an image as a BMP preview plus a native payload such
as TdxPNGImage, SVG rendering and extract_embedded_images(...) prefer the
native payload so PNG alpha is preserved. Plain 32-bit BMP alpha is preserved
when present; plain 24-bit BMP remains opaque.
Use schdoc.extract_embedded_images(output_dir) when writing embedded images
as standalone files. Direct image.image_data access is a preservation API: it
returns the raw Storage payload and may include Altium wrapper bytes before the
native image. Code that needs image files should not hash or write
image.image_data directly unless it intentionally wants the exact stored
payload.
AltiumSchDoc.to_svg(...) accepts SchSvgRenderOptions. Normal review output
includes a root viewBox in schematic pixel-canvas coordinates. Strict
native/oracle output from SchSvgRenderOptions.native_altium() omits the root
viewBox by default so comparison lanes can preserve the native export shape.
Set SchSvgRenderOptions(include_view_box=False) when a caller needs the
normal renderer profile without a root viewBox.
Start with:
hello_schdocschdoc_vertical_pin_svgschdoc_add_noteschdoc_note_commandschdoc_move_noteschdoc_add_harness_connectorschdoc_mutate_harness_connectorschdoc_add_sheet_symbolschdoc_mutate_sheet_symbolschdoc_insert_dblib_styleschdoc_cleanschdoc_svgschdoc_apply_dynamic_template
See API patterns for cross-cutting mutation and ownership guidance.