### Display Altium Schematic in a Window Source: https://github.com/vadmium/python-altium/blob/master/README.md This command displays an Altium schematic in a Tkinter window. Ensure TK is installed as a dependency. ```shell python3 altium.py --renderer tk schematic.SchDoc ``` -------------------------------- ### Render Schematic to SVG Source: https://context7.com/vadmium/python-altium/llms.txt Uses `vector.svg.Renderer` to draw schematic elements like rectangles, lines, and text into an SVG document. Ensure `start()` is called before drawing and `finish()` to close the SVG. ```python from vector import svg from contextlib import redirect_stdout from io import StringIO buf = StringIO() with redirect_stdout(buf): r = svg.Renderer( size=(500, 300), # internal units (1/100 inch) units="in", unitmult=1/100, # scale: 1 internal unit = 1/100 inch margin=10, line=1, down=-1, # y-axis points up (Altium convention) textbottom=True, ) r.addfont("font1", 10, "Arial", bold=False, italic=False) r.setdefaultfont("font1") r.start() # Draw shapes r.rectangle((50, 50), (200, 150), outline=(0, 0, 1), fill=(0.9, 0.9, 1), width=1) r.line((50, 50), (200, 150), colour=(1, 0, 0), width=0.5) r.ellipse((20, 10), offset=(300, 200), outline=(0, 0.5, 0)) r.arc((30, 30), 0, 270, offset=(400, 100), colour=(0.5, 0, 0.5)) r.text("Hello Altium", offset=(100, 250), horiz=r.CENTRE, vert=r.CENTRE, colour=(0, 0, 0), font="font1") # Sub-view with translation + rotation with r.view(offset=(250, 150), rotate=1) as v: v.hline(0, 40, colour=(0, 0, 0)) r.finish() print(buf.getvalue()[:300]) # # ``` -------------------------------- ### Integer Formats in Altium Files Source: https://github.com/vadmium/python-altium/blob/master/format.md Demonstrates various integer formats used in Altium files, including decimal, enumerated types, and bitfields. Default value for missing properties appears to be 0. ```plaintext |RECORD=31 ``` ```plaintext |OWNERPARTID=-1 ``` ```plaintext |RECORD=1 ``` ```plaintext |STYLE=1 ``` ```plaintext |COLOR=8388608 ``` ```plaintext |PINCONGLOMERATE=58 ``` -------------------------------- ### altium.Properties Source: https://context7.com/vadmium/python-altium/llms.txt A dict-like container for schematic record properties, offering typed accessors and unknown property detection. ```APIDOC ## altium.Properties — Schematic object property bag A dict-like container that holds the `|NAME=VALUE` properties of a single schematic record. Provides typed accessors and tracks which properties were accessed (for unknown-property detection via `check_unknown()`). ```python import altium from olefile import OleFileIO ole = OleFileIO("my_schematic.SchDoc") stream = ole.openstream("FileHeader") recs = list(altium.iter_records(stream)) # Skip file header record (index 0), get first schematic object stream.seek(0) next(altium.iter_records(stream)) # skip header record position stream.seek(0) gen = (altium.parse_properties(stream, r) for r in altium.iter_records(stream)) _header = next(gen) sheet_props = next(gen) # Typed property access record_id = sheet_props.get_int("RECORD") # 31 (Sheet) sheet_style = sheet_props.get_int("SHEETSTYLE") # 0..17 title_block = sheet_props.get_bool("TITLEBLOCKON") # True / False font_count = sheet_props.get_int("FONTIDCOUNT") # e.g. 2 # Check an expected value, warn if unexpected sheet_props.check("BORDERON", b"T") # Detect unread properties (useful for format research) import warnings with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") sheet_props.check_unknown() if w: print("Unhandled props:", [str(x.message) for x in w]) ``` ``` -------------------------------- ### Parse Altium Schematic File with altium.read() Source: https://context7.com/vadmium/python-altium/llms.txt Use `altium.read()` to open and parse an Altium schematic file. It returns the root sheet object, a storage stream, and embedded files. Inspect the `sheet.properties` for metadata and traverse the `.children` tree to access schematic elements. ```python import altium # Open and parse a schematic file with open("my_schematic.SchDoc", "rb") as f: sheet, storage_stream, storage_files = altium.read(f) # Inspect top-level sheet properties props = sheet.properties print("Sheet style index:", props.get_int("SHEETSTYLE")) # e.g. 0 (A4) print("Font count:", props.get_int("FONTIDCOUNT")) # e.g. 3 print("Title block on:", props.get_bool("TITLEBLOCKON")) # True/False # Walk the object tree def walk(obj, depth=0): record = obj.properties.get_int("RECORD") if obj.properties else None print(" " * depth + repr(obj), "record=", record) for child in obj.children: walk(child, depth + 1) walk(sheet) # Output (example): # Object(properties=<...>) record= 31 # Object(properties=<...>) record= 1 # COMPONENT # Object(properties=<...>) record= 2 # PIN # Object(properties=<...>) record= 41 # PARAMETER # Object(properties=<...>) record= 27 # WIRE # Object(properties=<...>) record= 25 # NET_LABEL ``` -------------------------------- ### Display Embedded Schematic Preview Source: https://context7.com/vadmium/python-altium/llms.txt The `schdocpreview.py` script reads a schematic data dump from stdin and displays the embedded preview bitmap in a Tkinter window. The image is a zlib-compressed, hex-encoded BGRA bitmap. ```bash # Extract the Additional stream and pipe it to the preview viewer # (Requires a tool that can dump the OLE stream as an INI-like text) python3 schdocpreview.py < schematic_preview.ini # Opens a Tkinter window showing the schematic's built-in preview thumbnail ``` -------------------------------- ### altium.overline Source: https://context7.com/vadmium/python-altium/llms.txt Decodes Altium's overline encoding (backslash escaping) into a list of text spans with overline information. ```APIDOC ## `altium.overline(name)` — Decode overlined net names Altium encodes overlined characters using backslash escaping (e.g., `\C\L\K\` for an overlined clock signal). This function decodes that encoding into a list of `{'text': ..., 'overline': True/False}` dicts compatible with the renderer's rich-text format. ```python import altium # Plain name — no overlines spans = altium.overline(b"VCC") print(spans) # [{'text': 'VCC'}] # Overlined name: backslash every other char signals overline region spans = altium.overline(b"\\C\\L\\K\\") print(spans) # [{'text': 'CLK', 'overline': True}] # Mixed: overlined prefix + plain suffix spans = altium.overline(b"\\N\\R\\E\\SET") # The renderer passes these spans directly to renderer.text(): # renderer.text(spans, offset=(x, y), font="font1") ``` ``` -------------------------------- ### `altium.read(file)` — Parse a `.SchDoc` file Source: https://context7.com/vadmium/python-altium/llms.txt Opens an OLE compound document `.SchDoc` file and returns a tuple containing the root schematic object, and streams for accessing embedded assets. This is the primary entry point for programmatic access to schematic data without rendering. ```APIDOC ## `altium.read(file)` — Parse a `.SchDoc` file ### Description Opens an OLE compound document `.SchDoc` file and returns a tuple of `(sheet_object, storage_stream, storage_files)`. The `sheet_object` is the root `Object` node whose `.children` tree contains every schematic element. `storage_stream` and `storage_files` give access to embedded binary assets (e.g., images). This is the entry point for programmatic access to schematic data without rendering. ### Parameters #### Path Parameters - **file** (file object) - Required - A file-like object opened in binary read mode. ### Response #### Success Response (tuple) - **sheet_object** (Object) - The root object node of the schematic. - **storage_stream** (Stream) - A stream for accessing embedded binary assets. - **storage_files** (Files) - Access to embedded binary assets. ### Request Example ```python import altium # Open and parse a schematic file with open("my_schematic.SchDoc", "rb") as f: sheet, storage_stream, storage_files = altium.read(f) # Inspect top-level sheet properties props = sheet.properties print("Sheet style index:", props.get_int("SHEETSTYLE")) # e.g. 0 (A4) print("Font count:", props.get_int("FONTIDCOUNT")) # e.g. 3 print("Title block on:", props.get_bool("TITLEBLOCKON")) # True/False # Walk the object tree def walk(obj, depth=0): record = obj.properties.get_int("RECORD") if obj.properties else None print(" " * depth + repr(obj), "record=", record) for child in obj.children: walk(child, depth + 1) walk(sheet) ``` ### Response Example ``` Object(properties=<...>) record= 31 Object(properties=<...>) record= 1 # COMPONENT Object(properties=<...>) record= 2 # PIN Object(properties=<...>) record= 41 # PARAMETER Object(properties=<...>) record= 27 # WIRE Object(properties=<...>) record= 25 # NET_LABEL ``` ``` -------------------------------- ### Convert Altium Schematic to SVG Source: https://github.com/vadmium/python-altium/blob/master/README.md Use this command to convert an Altium schematic file to an SVG image. The output is redirected to a file. ```shell python3 altium.py schematic.SchDoc > output.svg ``` -------------------------------- ### `altium.render(filename, Renderer)` — Render a schematic Source: https://context7.com/vadmium/python-altium/llms.txt The main rendering pipeline that reads a schematic file and dispatches objects to a specified renderer backend. Supports SVG output to stdout or an interactive Tkinter window. ```APIDOC ## `altium.render(filename, Renderer)` — Render a schematic ### Description The `render` class (used as a callable) is the main rendering pipeline. It calls `read()` internally, sets up the renderer with the correct sheet size and fonts, iterates every schematic object, and dispatches to the appropriate `handle_*` method. Pass `svg.Renderer` to write SVG to stdout, or `tk.Renderer` to open an interactive window. ### Parameters #### Path Parameters - **filename** (string) - Required - The path to the schematic file (`.SchDoc`). - **Renderer** (class) - Required - The renderer class to use (e.g., `svg.Renderer`, `tk.Renderer`). ### Request Example ```python import altium from vector import svg, tk # --- SVG output to stdout --- import sys from io import StringIO from contextlib import redirect_stdout buf = StringIO() with redirect_stdout(buf): altium.render("board.SchDoc", svg.Renderer) svg_data = buf.getvalue() print(svg_data[:200]) # output.svg) --- with open("output.svg", "w") as out: with redirect_stdout(out): altium.render("board.SchDoc", svg.Renderer) # --- Display in a TK window (blocks until window is closed) --- # altium.render("board.SchDoc", tk.Renderer) ``` ### Response #### Success Response - **SVG Output**: If `svg.Renderer` is used, SVG XML is printed to stdout. - **Tkinter Window**: If `tk.Renderer` is used, an interactive window is displayed. ### Response Example ```xml ``` ``` -------------------------------- ### Render Altium Schematic to SVG or TK with altium.render() Source: https://context7.com/vadmium/python-altium/llms.txt The `altium.render()` function processes a schematic file using a specified renderer. Use `svg.Renderer` for SVG output to stdout, or `tk.Renderer` for an interactive Tkinter window. This function handles the internal call to `read()` and the rendering pipeline. ```python import altium from vector import svg, tk # --- SVG output to stdout --- import sys from io import StringIO from contextlib import redirect_stdout buf = StringIO() with redirect_stdout(buf): altium.render("board.SchDoc", svg.Renderer) svg_data = buf.getvalue() print(svg_data[:200]) # output.svg) --- with open("output.svg", "w") as out: with redirect_stdout(out): altium.render("board.SchDoc", svg.Renderer) # --- Display in a TK window (blocks until window is closed) --- # altium.render("board.SchDoc", tk.Renderer) ``` -------------------------------- ### Accessing and Iterating Schematic Properties Source: https://context7.com/vadmium/python-altium/llms.txt Demonstrates how to access individual properties from a header object and iterate through records to parse schematic object properties. Use this for inspecting file metadata and individual schematic elements. ```python import altium from olefile import OleFileIO ole = OleFileIO("my_schematic.SchDoc") stream = ole.openstream("FileHeader") recs = list(altium.iter_records(stream)) # Skip file header record (index 0), get first schematic object stream.seek(0) next(altium.iter_records(stream)) # skip header record position stream.seek(0) gen = (altium.parse_properties(stream, r) for r in altium.iter_records(stream)) _header = next(gen) sheet_props = next(gen) # Typed property access record_id = sheet_props.get_int("RECORD") # 31 (Sheet) sheet_style = sheet_props.get_int("SHEETSTYLE") # 0..17 title_block = sheet_props.get_bool("TITLEBLOCKON") # True / False font_count = sheet_props.get_int("FONTIDCOUNT") # e.g. 2 # Check an expected value, warn if unexpected sheet_props.check("BORDERON", b"T") # Detect unread properties (useful for format research) import warnings with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") sheet_props.check_unknown() if w: print("Unhandled props:", [str(x.message) for x in w]) ``` -------------------------------- ### Iterate Raw Records in OLE Stream with altium.iter_records() Source: https://context7.com/vadmium/python-altium/llms.txt Use `altium.iter_records()` for low-level inspection of OLE streams within a schematic file. It yields tuples of `(record_type, record_length)` for each record, distinguishing between property-list (type 0) and binary (type 1) records. This is useful for debugging or custom parsing. ```python import altium from olefile import OleFileIO ole = OleFileIO("my_schematic.SchDoc") stream = ole.openstream("FileHeader") for record_type, record_length in altium.iter_records(stream): print(f"type={record_type}, length={record_length}") # type=0, length=92 # type=0, length=134 # ... ``` -------------------------------- ### Decoding Overlined Net Names Source: https://context7.com/vadmium/python-altium/llms.txt Use `overline` to decode Altium's backslash-escaped net names into a list of text spans, where each span can be marked as overlined. This format is compatible with rich-text rendering. ```python import altium # Plain name — no overlines spans = altium.overline(b"VCC") print(spans) # [{'text': 'VCC'}] # Overlined name: backslash every other char signals overline region spans = altium.overline(b"\\C\\L\\K\\") print(spans) # [{'text': 'CLK', 'overline': True}] # Mixed: overlined prefix + plain suffix spans = altium.overline(b"\\N\\R\\E\\SET") # The renderer passes these spans directly to renderer.text(): # renderer.text(spans, offset=(x, y), font="font1") ``` -------------------------------- ### Extract Raw Schematic Properties Source: https://context7.com/vadmium/python-altium/llms.txt The `dump.py` script extracts and prints all `|KEY=VALUE` property lines from OLE streams in a `.SchDoc` file to standard output. This is useful for reverse-engineering or diagnosing parse issues. ```bash # Print all raw property records to stdout python3 dump.py my_schematic.SchDoc # Sample output: # |HEADER=Protel for Windows - Schematic Capture Binary File Version 5.0|WEIGHT=42 # |RECORD=31|FONTIDCOUNT=2|SIZE1=10|FONTNAME1=Times New Roman|... # |RECORD=1|OWNERPARTID=-1|UNIQUEID=ABCDEF|LIBREFERENCE=R10k|... # |RECORD=2|DESIGNATOR=1|NAME=IN|PINLENGTH=30|ELECTRICAL=0|... ``` -------------------------------- ### Line Width Enumeration Source: https://github.com/vadmium/python-altium/blob/master/format.md Defines line widths based on integer values. Omitted properties default to 4 mil. ```plaintext |LINEWIDTH ``` -------------------------------- ### Boolean Values in Altium Files Source: https://github.com/vadmium/python-altium/blob/master/format.md Represents boolean properties using 'T' for true and 'F' for false. When false, the property is often omitted. ```plaintext |ISHIDDEN=T|PARTIDLOCKED=F ``` -------------------------------- ### Real Number Formatting Source: https://github.com/vadmium/python-altium/blob/master/format.md Illustrates the format for real numbers, typically used for encoding angles with a fractional part. Property is omitted when the value is zero. ```plaintext |ENDANGLE=360.000 ``` -------------------------------- ### altium.get_sheet_style Source: https://context7.com/vadmium/python-altium/llms.txt Resolves the `SHEETSTYLE` integer to a human-readable name and dimensions, handling custom sizes and orientation. ```APIDOC ## `altium.get_sheet_style(sheet)` — Resolve sheet size Maps the `SHEETSTYLE` integer to a human-readable name and a `(width, height)` tuple in 1/100" units. Handles custom sheet sizes and orientation. ```python import altium from olefile import OleFileIO ole = OleFileIO("my_schematic.SchDoc") stream = ole.openstream("FileHeader") gen = (altium.parse_properties(stream, r) for r in altium.iter_records(stream)) _header = next(gen) sheet_obj = altium.Object(properties=next(gen)) name, (width, height) = altium.get_sheet_style(sheet_obj.properties) print(f"Sheet: {name}, {width * altium.UNIT_MM:.1f} mm × {height * altium.UNIT_MM:.1f} mm") # Sheet: A4, 292.1 mm × 193.0 mm # Unit conversion constants print(altium.UNIT_MM) # 0.254 (mm per internal unit) print(altium.UNIT_MILS) # 10 (mils per internal unit) print(altium.INCH_SIZE) # 100 (internal units per inch) ``` ``` -------------------------------- ### Programmatic Schematic Data Extraction Source: https://context7.com/vadmium/python-altium/llms.txt Read schematic data programmatically to obtain an in-memory object tree. This enables custom applications for net-list extraction, BOM generation, and more. ```python import altium schematic_data = altium.read("schematic.SchDoc") # schematic_data is now a full in-memory object tree ``` -------------------------------- ### Component Object Properties Source: https://github.com/vadmium/python-altium/blob/master/format.md Properties for defining a schematic component. Includes library reference, description, part count, display modes, and positional information. ```plaintext |RECORD=1 ``` ```plaintext |LIBREFERENCE ``` ```plaintext |COMPONENTDESCRIPTION|%UTF8%COMPONENTDESCRIPTION|COMPONENTKIND=3 ``` ```plaintext |PARTCOUNT ``` ```plaintext |DISPLAYMODECOUNT ``` ```plaintext |INDEXINSHEET ``` ```plaintext |OWNERPARTID=-1|LOCATION.X|LOCATION.Y ``` ```plaintext |DISPLAYMODE ``` ```plaintext |ISMIRRORED=T|ORIENTATION ``` ```plaintext |CURRENTPARTID ``` ```plaintext |LIBRARYPATH ``` ```plaintext |SOURCELIBRARYNAME ``` ```plaintext |SHEETPARTFILENAME=* ``` ```plaintext |TARGETFILENAME|UNIQUEID ``` ```plaintext |AREACOLOR=11599871|COLOR=128 ``` ```plaintext |PARTIDLOCKED|DESIGNATORLOCKED ``` ```plaintext |NOTUSEDBTABLENAME|DESIGNITEMID|DATABASETABLENAME|ALIASLIST ``` ```plaintext |PINSMOVEABLE ``` -------------------------------- ### `altium.iter_records(stream)` — Low-level record iterator Source: https://context7.com/vadmium/python-altium/llms.txt Yields tuples of record type and length for each record within a raw OLE stream. This is a low-level utility for inspecting the structure of schematic files. ```APIDOC ## `altium.iter_records(stream)` — Low-level record iterator ### Description Yields `(type, length)` tuples for each record in a raw OLE stream. `type=0` indicates a property-list record; `type=1` is a binary record. This is a low-level utility used by `dump.py` and `ascii.py` for inspection purposes. ### Parameters #### Path Parameters - **stream** (stream object) - Required - A stream object from an OLE file. ### Response #### Success Response (iterator) - **record_type** (int) - The type of the record (0 for property-list, 1 for binary). - **record_length** (int) - The length of the record in bytes. ### Request Example ```python import altium from olefile import OleFileIO ole = OleFileIO("my_schematic.SchDoc") stream = ole.openstream("FileHeader") for record_type, record_length in altium.iter_records(stream): print(f"type={record_type}, length={record_length}") # type=0, length=92 # type=0, length=134 # ... ``` ### Response Example ``` type=0, length=92 type=0, length=134 type=1, length=512 ``` ``` -------------------------------- ### altium.iter_fonts Source: https://context7.com/vadmium/python-altium/llms.txt Enumerates fonts defined on a sheet, yielding dictionaries with font properties like ID, line height, family, and style. ```APIDOC ## `altium.iter_fonts(sheet)` — Enumerate sheet fonts Yields one `dict` per font defined on the sheet, with keys `id`, `line` (line height), `family`, `italic`, `bold`, and `underline`. ```python import altium from olefile import OleFileIO ole = OleFileIO("my_schematic.SchDoc") stream = ole.openstream("FileHeader") gen = (altium.parse_properties(stream, r) for r in altium.iter_records(stream)) _header = next(gen) sheet_props = next(gen) for font in altium.iter_fonts(sheet_props): print(font) # {'id': 1, 'line': 10, 'family': 'Times New Roman', 'italic': False, 'bold': False, 'underline': False} # {'id': 2, 'line': 8, 'family': 'Arial', 'italic': False, 'bold': True, 'underline': False} ``` ``` -------------------------------- ### Parse Property-List Record with altium.parse_properties() Source: https://context7.com/vadmium/python-altium/llms.txt Decode a property-list record from a stream using `altium.parse_properties()`. This function reads a specified length from the stream and returns a `Properties` object, parsing a pipe-delimited ASCII payload. It's useful when manually inspecting records obtained via `iter_records()`. ```python import altium from olefile import OleFileIO ole = OleFileIO("my_schematic.SchDoc") stream = ole.openstream("FileHeader") records = altium.iter_records(stream) header_rec = next(records) header = altium.parse_properties(stream, header_rec) ``` -------------------------------- ### Header Object Properties Source: https://github.com/vadmium/python-altium/blob/master/format.md Properties specific to the Header object in the FileHeader stream. The HEADER property identifies the file version. ```plaintext |HEADER=Protel for Windows - Schematic Capture Binary File Version 5.0 ``` ```plaintext |WEIGHT ``` ```plaintext |MINORVERSION=2|UNIQUEID ``` -------------------------------- ### Altium Record Type Constants Source: https://context7.com/vadmium/python-altium/llms.txt Provides named constants for schematic object record IDs used to identify object types when traversing the parsed object tree. Use these constants to filter objects by type. ```python import altium # Record type reference print(altium.Record.COMPONENT) # 1 print(altium.Record.PIN) # 2 print(altium.Record.WIRE) # 27 print(altium.Record.NET_LABEL) # 25 print(altium.Record.POWER_PORT) # 17 print(altium.Record.SHEET) # 31 # Usage: filter objects by type with open("my_schematic.SchDoc", "rb") as f: sheet, _, _ = altium.read(f) def find_by_record(node, target_record, result=None): if result is None: result = [] if node.properties and node.properties.get_int("RECORD") == target_record: result.append(node) for child in node.children: find_by_record(child, target_record, result) return result components = find_by_record(sheet, altium.Record.COMPONENT) wires = find_by_record(sheet, altium.Record.WIRE) print(f"Found {len(components)} components, {len(wires)} wires") ``` -------------------------------- ### `altium.parse_properties(stream, header)` — Decode a property-list record Source: https://context7.com/vadmium/python-altium/llms.txt Reads a specified number of bytes from a stream and decodes them into a `Properties` object, typically from a pipe-delimited ASCII payload. Useful for manual inspection of records. ```APIDOC ## `altium.parse_properties(stream, header)` — Decode a property-list record ### Description Reads `length` bytes from `stream` and returns a `Properties` object populated from a `|KEY=value|KEY=value` pipe-delimited ASCII payload. Useful when combining `iter_records` with manual record inspection. ### Parameters #### Path Parameters - **stream** (stream object) - Required - The stream to read from. - **header** (tuple) - Required - The header tuple obtained from `iter_records`, containing record type and length. ### Response #### Success Response (Properties object) - **Properties object** - An object containing key-value pairs decoded from the property-list record. ### Request Example ```python import altium from olefile import OleFileIO ole = OleFileIO("my_schematic.SchDoc") stream = ole.openstream("FileHeader") records = altium.iter_records(stream) header_rec = next(records) header = altium.parse_properties(stream, header_rec) # Example of accessing properties print("Sheet Name:", header.get_string("SheetName")) print("Sheet Height:", header.get_int("SheetHeight")) ``` ### Response Example ``` Sheet Name: MySheet Sheet Height: 1000 ``` ``` -------------------------------- ### Render Schematic to Tkinter Canvas Source: https://context7.com/vadmium/python-altium/llms.txt Utilizes `vector.tk.Renderer` to draw schematic elements onto a Tkinter canvas. The `finish()` method enters `tkinter.mainloop()`, blocking until the window is closed. Pillow is required for image support. ```python from vector import tk as tkvector # Typically invoked via altium.render(), but can be used standalone: r = tkvector.Renderer( size=(1150, 760), # A4 in 1/100-inch units units="in", unitmult=1/100, margin=10, line=1, down=-1, ) r.addfont("font1", 10, "Times New Roman") r.setdefaultfont("font1") r.start() r.rectangle((100, 100), (400, 300), outline=(0, 0, 0), fill=(1, 1, 0.8)) r.text("Schematic Title", offset=(250, 200), horiz=r.CENTRE, vert=r.CENTRE, colour=(0, 0, 0), font="font1") r.finish() # Opens window — blocks here until user closes ``` -------------------------------- ### RGB Color Representation Source: https://github.com/vadmium/python-altium/blob/master/format.md Shows how RGB colors are represented using integer values, corresponding to Red, Green, and Blue components. Inherited from Delphi TColor data type. ```plaintext |COLOR=128|AREACOLOR=11599871 ``` -------------------------------- ### Resolving Sheet Style and Dimensions Source: https://context7.com/vadmium/python-altium/llms.txt Use `get_sheet_style` to map the integer `SHEETSTYLE` property to a human-readable name and dimensions. This function handles custom sizes and orientation, providing output in 1/100" units. ```python import altium from olefile import OleFileIO ole = OleFileIO("my_schematic.SchDoc") stream = ole.openstream("FileHeader") gen = (altium.parse_properties(stream, r) for r in altium.iter_records(stream)) _header = next(gen) sheet_obj = altium.Object(properties=next(gen)) name, (width, height) = altium.get_sheet_style(sheet_obj.properties) print(f"Sheet: {name}, {width * altium.UNIT_MM:.1f} mm × {height * altium.UNIT_MM:.1f} mm") # Sheet: A4, 292.1 mm × 193.0 mm # Unit conversion constants print(altium.UNIT_MM) # 0.254 (mm per internal unit) print(altium.UNIT_MILS) # 10 (mils per internal unit) print(altium.INCH_SIZE) # 100 (internal units per inch) ``` -------------------------------- ### Enumerating Sheet Fonts Source: https://context7.com/vadmium/python-altium/llms.txt Iterate through fonts defined on a sheet using `iter_fonts`. Each font is returned as a dictionary containing its ID, line height, family, and style attributes (italic, bold, underline). ```python import altium from olefile import OleFileIO ole = OleFileIO("my_schematic.SchDoc") stream = ole.openstream("FileHeader") gen = (altium.parse_properties(stream, r) for r in altium.iter_records(stream)) _header = next(gen) sheet_props = next(gen) for font in altium.iter_fonts(sheet_props): print(font) # {'id': 1, 'line': 10, 'family': 'Times New Roman', 'italic': False, 'bold': False, 'underline': False} # {'id': 2, 'line': 8, 'family': 'Arial', 'italic': False, 'bold': True, 'underline': False} ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.