On This Page (7)
Schematic Paint IR
Schematic Paint IR A0 (SchPaintIR) is the unified drawing pipeline behind all schematic rendering in altium-monkey: .SchDoc sheets, .SchLib symbols, compiled physical pages, and individual record previews.
Use it when you need to:
- render schematics or library symbols to SVG (
to_svg,symbol_to_svg,to_physical_svg) - render schematics or symbols directly to PNG (
to_paint_png,symbol_to_paint_png,SchPaintPngRenderer) - export a strict, schema-validated analytic display list (
to_paint_ir,symbol_to_paint_ir,to_physical_paint_ir) for custom viewers or downstream tools - control editor adornments (grid, hotspots, automatic junction colors and layering) independently of document mutation
Mental Model
Rendering happens in two steps:
- Produce a
SchPaintIRscene: resolves parameters, font metrics, paint order, clips, transforms, and normalized PNG image resources in source mil coordinates. Controlled bySchPaintView. - Lower to an output:
- SVG (
SchPaintSvgRenderer/.to_svg(options=SchPaintSvgOptions(...))) - PNG (
SchPaintPngRenderer/.to_paint_png(png_options=SchPaintPngOptions(...))) - JSON (
scene.write_json(...)/scene.to_json_text(), conforming toaltium_monkey.sch_paint_ir.a0)
- SVG (
Semantic connectivity (nets, pins, components, hierarchy) stays in AltiumDesign.to_json() and Netlist.to_json() rather than being encoded into drawing commands.
Quick Start
from altium_monkey import (
AltiumSchDoc,
AltiumSchLib,
SchJunctionColors,
SchPaintPngOptions,
SchPaintSvgOptions,
SchPaintView,
)
# 1. Schematic SVG (text elements vs. portable outlined paths)
schdoc = AltiumSchDoc("sheet.SchDoc")
svg = schdoc.to_svg(options=SchPaintSvgOptions())
portable_svg = schdoc.to_svg(options=SchPaintSvgOptions(text_mode="paths"))
# 2. Editor view with custom automatic junction colors
editor_view = SchPaintView.editor(
junction_colors=SchJunctionColors(wire_bgr=0, bus_bgr=0x800000),
auto_junctions_on_top=True,
)
editor_svg = schdoc.to_svg(
view=editor_view,
options=SchPaintSvgOptions(
include_editor_grid=True,
include_editor_hotspots=True,
),
)
# 3. Export Paint IR A0 JSON or raster PNG (set dpi= or width_px=/height_px=)
scene = schdoc.to_paint_ir(view=SchPaintView.static_scene())
scene.write_json("sheet.paint-ir.json")
png_bytes = schdoc.to_paint_png(png_options=SchPaintPngOptions(dpi=192.0))
# 4. Library symbol rendering
schlib = AltiumSchLib("parts.SchLib")
symbol_svg = schlib.symbol_to_svg("R_0603", part_id=1, display_mode=0)Presentation Views (SchPaintView)
| Factory | Grid & hotspots | Intended use |
|---|---|---|
SchPaintView.static_scene(...) | Off (default) | Clean documentation/review drawings |
SchPaintView.editor(...) | On | Altium editor-style previews and inspections |
Both presets accept:
junction_colors=SchJunctionColors(wire_bgr=..., bus_bgr=...)— explicit Altium BGR colors for automatic wire and bus/harness junctions (persisted manualJunctionrecords keep their authored color).auto_junctions_on_top=True— draw automatic junction dots above document artwork instead of interleaved in source order.
SVG Options (SchPaintSvgOptions)
Key options on SchPaintSvgOptions:
text_mode:"text"(default, compact SVG<text>) or"paths"(outlines every glyph into vector paths for viewers that lack host fonts).include_view_box:Trueby default;Falseomits only the rootviewBox.wrap_components/include_group_metadata: opt into component wrappers and occurrence/role/paint-pass attributes on SVG groups.include_editor_grid/include_editor_hotspots: emit editor grid and hotspot adornments when rendering fromSchPaintView.editor().embed_bundled_fallback_fonts: unsupported (TrueraisesSchPaintRenderError); usetext_mode="paths"for font-independent SVGs.
Single-Record & Physical-Page Rendering
- Single record: build a
SchPaintContext(SchPaintContext.for_document,for_component, orfor_symbol), then callrecord.to_paint_ir(ctx)orrecord.to_svg(ctx, svg_options=...).record.to_svg(...)returns a complete standalone SVG document string. - Multi-channel, hierarchical, and variant-aware projects: load the
.PrjPcbwithAltiumDesign.from_prjpcb(...), optionally select a project assembly variant (design.project.set_current_variant("A")), and render compiled physical pages viadesign.to_physical_svg(page_occurrence_ref),design.to_physical_paint_ir(page_occurrence_ref), orSchPaintPngRenderer(...).render(paint_ir)so Not Fitted components and variant special strings render automatically. Useget_physical_document_id_for_page(page_ref)when correlating rendered output with Design/Netlist JSON sidecars rather than decoding opaque Paint IR source keys.
Migrating From Legacy GOTIR
The legacy schematic Geometry Operation Tree IR (GOTIR) producer, renderer, and context options have been removed with no compatibility aliases:
| Removed surface | Current Paint IR A0 surface |
|---|---|
AltiumSchDoc.to_ir() | AltiumSchDoc.to_paint_ir() |
AltiumSchLib.symbol_to_ir(...) | AltiumSchLib.symbol_to_paint_ir(...) |
AltiumDesign.to_physical_ir(page_ref) | AltiumDesign.to_physical_paint_ir(page_ref) |
Record to_geometry(...) | Record to_paint_ir(SchPaintContext) |
Doc/Lib/record to_paint_svg, Lib symbol_to_paint_svg | Canonical to_svg / symbol_to_svg |
Design to_physical_paint_svg | to_physical_svg |
SchSvgRenderOptions and legacy contexts/profiles | SchPaintSvgOptions and SchPaintContext |
Related Pages
- Text & Font Rendering — schematic font resolution, HarfBuzz/Skia vs. GDI+ path lowering, and PNG anti-aliasing
- SVG Format Contract — DOM attributes and Design JSON sidecar linkage
- JSON Schemas & TypeSpec —
altium_monkey.sch_paint_ir.a0schema and TypeSpec definitions - Examples:
schdoc_svg,schdoc_vertical_pin_svg,sch_paint_ir_views_and_pngandschlib_svg