coffeenmusic/altium-mcp
Altium Model Context Protocol server and Altium API script
c0f86dabd0ffaltiummcp0.1.0 in pyproject.tomlPaths from tool input into commands, SQL, files and URLs
How much power the tools give an agent over the machine
Hidden instructions and poisoning in text for the model
Known vulnerabilities in the packages the server uses
How the server reads credentials and where they can go
Whether the tools do only what their descriptions say
How far the analysis went
The scanner traces each tool from its input to the operations its code performs, and here it could not follow every path. Code Safety is shown as partly traced instead of a score: no finding there is not a clean result. The score of Capability Exposure counts only what it could follow.
- In 312 places a tool's input is handed to a function whose name matches several definitions in the code; the scanner could not tell which one runs, so it stopped there
- 1 of 90 tools, prompts and resources could not be followed through the code
- 1 place in the code registers tools whose names are computed at run time; how many tools that makes cannot be read from the code
Top risks in plain words
- CRITICAL8 production dependencies have known vulnerabilities (worst: critical).
- HIGHTools
check_schematic,create_symbols_batch,get_outjob_settings,render_sheetread or write any file path by design: an agent steered by prompt injection can use them that way.
How to use it safely
Practical steps from what we found in this server. They lower the risk; they do not replace a review of the code.
- Give it only the folder it needs
check_schematic,create_symbols_batch,get_outjob_settings,render_sheetcan read or write any file path. Mount a single project folder, read-only where you can. - Turn off the tools you do not use
Most MCP clients let you disable single tools. If you do not need
check_schematic,create_symbols_batch,get_outjob_settingsand 1 more, switch them off. - Give it a narrowly scoped token
Its code reads credentials or environment variables. Use a key limited to what this server needs, not your main one.
- Update its vulnerable packages
Use
anyio4.14.2 or later,certifi2026.10.18 or later,h110.16.0 or later,idna3.15 or later and 4 more. - Keep confirmations on
Leave your MCP client's confirmation prompt on for tools that change files, run commands or send data.
What its tools can do on your machine
The server offers 90 tools. When an AI agent calls them, this is what their code can do on the machine where the server runs, as traced in the source. Tools that call code the scanner could not follow may do more.
ensure_altium_script_skill, get_footprint_primitives, run_altium_script, run_drcauto_place_silkscreen, build_schematic, check_objects_drc, check_orientation, check_placement, check_routing and 78 moreauto_place_silkscreen, get_screenshotNo tool was seen to: connect to the internet or other hosts; read passwords, tokens or keys; touch sensitive locations.
Where its requests and secrets go
Read from the names along each tool's calls, not from a run: what the code says, not every address it may reach at run time.
The literal addresses the tools' requests name.
- None: no request names a fixed host.
Constants or settings that start an address; the value comes from configuration.
- None seen.
Credential-like environment variables. Give the server a key with the least access it needs.
- None: no credential-like variable is read by the tools.
Text it brings in from outside
Text that reaches the model from outside: an instruction hidden in it can steer the agent (prompt injection). Treat what these tools return as data, not as orders.
- files84 tools · auto_place_silkscreen, build_schematic, check_objects_drc +81
Tool annotations
No tool declares MCP annotations (readOnlyHint, destructiveHint and the rest). Clients use them to decide what to confirm; directories such as Anthropic's and OpenAI's ask for them.
Tools, prompts and resources (90: 90 tools)
Open a row for its full description. Chips show what its code can reach, and which risky capability its own description declares.
check_schematictool Check a schematic sheet for drafting problems that make it hard to read.Filesoutside textReads/writes files
Check a schematic sheet for drafting problems that make it hard to read.
Run it after drawing or editing a sheet (build_schematic, run_altium_script
or by hand), fix what it reports, and run it again. It reads the SAVED
file and does not need Altium, so save the sheet first; unsaved edits are
not seen.
Issue types, most important first:
* pin_tap - a two-pin part (decoupling cap, pull-up) joins its net AT its
own pin. Move the part so a short wire (a couple of grids) runs from
the pin to a junction on the net; suggest.junction_at shows where.
* label_not_at_end - a net label sits along a wire, away from the wire's
free end. Put it at the end (suggest gives the point).
* label_justification - a label at the free end whose text hangs off
the end of the wire. Justify it so the text runs back along the wire:
bottom-right (2) when the wire ends to the right, bottom-left (0)
when it ends to the left. A middle-justified (3/5) label anchored on
the end, reading outward like a port, is also accepted.
* sheet_entry_margin - a sheet symbol's first entry sits well below its
top edge. Altium's default is one grid (100 mil; 3 mm on a 1 mm grid);
extra room at the bottom is fine.
* sheet_symbol_text - a sheet symbol's designator or file name is not
above it. Both go above: file name on the top edge, designator a line
(100 mil) above it, both bottom-left justified at the left edge.
* label_orientation, label_off_wire, dangling_wire, wire_through_body.
* pin_off_grid - a part whose pins sit a few microns (up to 1 mil) off
the grid. Every wire drawn to them comes out slanted. When the part
itself is on the grid its drawing was shifted from its origin. When
every pin is off by the same amount, suggest gives the fix:
move_component_to (an on-grid position for edit_schematic's
move_component) when the whole part is that far off the grid, else
shift_contents_by. Pins off by different amounts get no suggestion:
the symbol needs fixing in its library.
* slanted_wire - a wire segment a little (1 um to half a grid) out of
level or plumb. It looks straight, but dragging a part on it turns it
diagonal. Usually a symbol whose pins are off the grid (then the
issue names the pin) or coordinates rounded to whole mils.
suggest.move_end/to give the end to move, at full precision:
delete_at the wire and add_wire it again with the new end.
* text_overlap - a designator, parameter, net label or port text
overlapping a wire, a pin, a part or other text. For part text the
issue carries suggest.texts: positions (x, y, justification) for the
designator and each visible parameter that collide with nothing, e.g.
designator left and value right of a vertical cap.
Coordinates are in the sheet's units ("unit": mm for a metric grid,
otherwise mil) with Altium's origin at the bottom left.
Args:
path: a .SchDoc, a .PrjPcb (every sheet it lists), or a folder (every
.SchDoc in it, not recursive).
max_issues_per_sheet: cap on issues listed per sheet; counts are
always complete.
Returns:
JSON: per sheet, the issue counts and the issues.create_symbols_batchtool Create many schematic symbols, or edit existing ones, in a singleFilesoutside textReads/writes files
Create many schematic symbols, or edit existing ones, in a single
Altium script run.
Use instead of repeated create_schematic_symbol calls when creating
more than a handful of symbols (bulk library imports/migrations): one
script launch instead of one per symbol, and pipe-delimited plain text
instead of JSON so field text (commas, brackets, spaces) is preserved
exactly. Verified by exact round-trips of a complete 284-symbol
production library.
Args:
spec_file (str): Path to a plain-text spec file, one record per line:
LIBRARY|<path to .SchLib> (optional first line: opens/focuses;
an already-open library is only
focused, never reloaded)
SYMBOL|<name>|<description>|<part_count>
PIN|<same pipe fields as create_schematic_symbol pins>
GRAPHIC|<same entry format as create_schematic_symbol graphics>
EDITSYMBOL|<name> edit an existing symbol instead (its pins
and graphics are left alone; a missing
symbol is reported as failed, never created)
COMMENT|<text>[|<visible 1/0>] set the Comment (empty text
is allowed); hidden unless visible is 1
DESCRIPTION|<text> set the Description
SYMPARAM|<name>|<value>|<visible 1/0>[|x|y[|justification[|font]]]
add a symbol parameter, or replace one with
that name. By default, visible ones without
x|y go below the body's bottom-left corner,
left-aligned, 100 mil apart in record order
(leave a field empty to skip it and still
give a later one). justification:
bottom_left, bottom_center, bottom_right,
center_left, center, center_right, top_left,
top_center or top_right. font: <font
name>:<size>, e.g. "Arial:10" (resolved by
name, so it works in any document). Omitted
fields keep the parameter's own. A parameter
the tool positions gets Autoposition off, so
Altium does not move it later.
PINPARAM|<pin number>|<name>|<value> add (or replace) a hidden
parameter on every pin with that number
PINDESC|<pin number>|<text> set the Description of every pin
with that number
PINSYMBOL|<pin number>|<edge>|<symbol> set an IEEE symbol of
every pin with that number. edge: inside,
inside_edge, outside_edge or outside.
symbol: a TIeeeSymbol name without the
leading "e", any case - none, dot, clock,
activelowinput, activelowoutput, schmitt,
analogsignalin, digitalsignalin, opencollector,
hiz, ... (the full list is in the
altium-script skill, SCH_API_Reference.md,
TIeeeSymbol). An unknown edge or symbol is
reported under problems.
PINFUNC|<pin number>|<F1>/<F2>/... optional: replace the
Functions list (Properties panel > Pin >
Functions) of every pin with that number,
in the order given, e.g.
PINFUNC|23|ETH1_MDIO/USART2_TX/TIM2_CH3.
Use it only when the user asks for pin
functions; nothing sets them otherwise, not
even from a pin name with '/' in it. Names
cannot contain '/' or '|'. A script cannot
clear the list, so an empty one is reported
under problems; Altium merges repeated names,
and a stored list that differs is reported.
These records work after SYMBOL and EDITSYMBOL alike.
Each SYMBOL or EDITSYMBOL line starts a new symbol; the other
records belong to the most recent one.
Every created or edited symbol is one undo step and marks the library
as modified; nothing is saved - the user saves the library.
Returns:
str: JSON object with created and edited counts, a failed name list
and problems (e.g. a pin number not in the symbol, an unknown
IEEE symbol or justification)get_outjob_settingstool Read an .OutJob file from disk and return its outputs, containers and settings.Filesoutside textReads/writes files
Read an .OutJob file from disk and return its outputs, containers and settings.
Works without Altium and on OutJobs that are not open. It reads the SAVED
file: changes not yet saved in Altium are not visible.
Notes for interpreting the result:
- An output is generated when it is connected to a container
(connected_containers non-empty). The per-output "enabled" flag mirrors
OutputEnabledN in the file and does not always match the UI.
- Gerber layers are decoded from Altium V7 layer IDs; unknown IDs are
reported as "Unknown layer 0x...".
Args:
outjob_path (str): Full path to the .OutJob file
include_raw_settings (bool): Also return raw_settings, the output's
settings as the file has them, for outputs with a decoded
summary. It doubles the reply. Outputs without a summary always
have raw_settings.
Returns:
str: JSON with path, group_name, variant, containers (name, type,
output paths, file name expression, add_to_project) and outputs
(type, name, document_path, variant, connected_containers and a
decoded summary for Gerber, NC Drill, test points, pick and
place and print outputs, or sections by name for a BOM)render_sheettool Draw a schematic sheet, or part of it, as a picture: wires, buses,Reads/writes files
Draw a schematic sheet, or part of it, as a picture: wires, buses,
junctions, component bodies with pins, net labels, power ports, ports,
sheet symbols and visible texts.
Read from the .SchDoc file, so Altium need not have it open and nothing
in Altium changes; changes not yet saved in Altium are not shown.
Args:
sheet_path (str): Full path of the .SchDoc.
bbox (list): [x1, y1, x2, y2] in sheet coordinates (Altium's origin
at the bottom left), in unit. Default everything drawn.
dpi (float): Pixels per inch of sheet (default 150); lowered so the
longer side stays within 4000 pixels.
unit (str): "mil" (default) or "mm".
Returns:
JSON (bbox in mils, dpi, size) and the PNG(name computed at run time)tool
No description.
auto_place_silkscreentool Bulk-place designators with the Silkscreen Auto Placer script - step 1 ofFilesEnv varsoutside text
Bulk-place designators with the Silkscreen Auto Placer script - step 1 of
silkscreen cleanup. Then finish by hand with the other silkscreen tools.
Runs a headless port of the AutoPlaceSilkscreen script inside Altium. For
every part, smallest first, it tries the enabled autopositions on an
offset grid with shrinking text, then a retry pass (rotation flip, wider
grid) and a 2nd-pass "wiggle" search up to 100 mil out. It avoids pads,
component bodies, other silk and (optionally) vias, and keeps the Board
Outline Clearance rule's distance from the board edge. Typically 80-95%
of designators end up placed; the rest are handled per failed_action.
Everything is one undo step. A whole-board run moves every designator:
ask the user to save the board first.
It is fast and good at the bulk, but it does not judge readability:
labels can land far from their part (2nd-pass label blocks), next to a
neighbour, or over open vias when avoid_vias is off. Always follow up:
1. check_silkscreen - lists what needs work (failed designators, DRC,
ambiguous or distant labels).
2. view_silkscreen / get_designator_options - look at each problem area
and find legal spots.
3. set_designator_positions - place them (dry_run first for neighbours).
Options default to the settings last saved by the script's GUI
(AutoPlaceSilkscreen.ini) when use_saved_settings is on, else the GUI's
defaults. Any argument given here overrides them.
Args:
designators (list, optional): Only place these designators. Omit for
the whole board (or the selection with selected_only).
selected_only (bool): Place only the components selected in Altium.
failed_action (str): What to do with designators that could not be
placed: "center" (centre them on their part, where
check_silkscreen flags them), "hide", or "restore" (put them back
where they were).
avoid_vias (bool): Treat vias as obstacles.
rotation_strategy (str): "component", "horizontal", "along_side",
"along_axis", "along_pins" or "klc" (KLC style).
positions (list): Autopositions to try, in order: TopCenter,
CenterRight, BottomCenter, CenterLeft, TopLeft, TopRight,
BottomLeft, BottomRight.
try_altered_rotation (bool): Also try the text turned 90 degrees.
second_pass (bool): Run the wider "wiggle" search for failures.
unhide_all (bool): Show hidden designators first so they get placed.
auto_hide (list): Designator prefixes to hide instead of placing,
e.g. ["TP", "MT", "FID"]; [] hides none.
allow_under (list): Designators whose bodies silk may cover.
text_height_mils (float): Fixed text height; 0 = size from the part
(shrinks to 25 mil when needed).
stroke_width_mils (float): Fixed stroke width; 0 = from the height.
position_delta_mils (float): Extra gap between autoposition and part.
component_outline_layer (str): Mechanical layer holding component
bodies (default "Mechanical 13" or a "Component Outline" layer).
use_saved_settings (bool): Start from the GUI's saved settings.
Returns:
str: JSON with placed/failed counts per pass, the failed designators,
the settings used and the next step.build_schematictool Build a wired schematic on a NEW sheet from a circuit description.Filesoutside text
Build a wired schematic on a NEW sheet from a circuit description.
READ dev/SCHEMATIC_CONVENTIONS.md BEFORE CALLING. This tool places exactly
what it is given; it does not lay out or correct spacing. The conventions
file records the drafting rules that make the result readable, each one
learned by getting it wrong. The ones that most often produce a plausible
but wrong sheet:
* A pin's connection point is NOT Pin.Location - it is PinLength further
along the pin. Do not guess coordinates. Call with parts only first,
read the returned pin_map, then call again with wires routed from those
measured coordinates.
* Never run a riser in a pin's connection column; it drives through every
pin sharing that column.
* Give a shunt part one grid of wire between its pin and the node it taps,
rather than putting the junction on the pin.
* A net label that does not TOUCH its wire names nothing.
* A shunt part occupies the band below its rail. Do not route another net
through that band - the wire will pass through the symbol body.
* A ground port's "GND" label is always drawn (ShowNetName cannot hide it)
and occupies ~300 mil below the port. Keep wires out of that band.
Once the sheet is saved, run check_schematic on it and fix what it finds.
Args:
parts: component dicts. Required keys: designator, symbol_library
(full path of a .SchLib file; .IntLib is not supported),
symbol, x, y (mils). Optional: design_item_id, orientation (0-3),
mirror (0/1), comment, description, footprint,
parameters ({name: value}).
wires: each a flat list of alternating x,y in mils, e.g.
[3900, 3000, 5300, 3000, 5300, 4900] - two segments, three points.
junctions: [{"x":..,"y":..}] - only where 3+ branches actually meet.
net_labels: [{"x":..,"y":..,"orientation":0,"text":"LED+"}] - the
coordinate must lie on a wire.
power_ports: [{"x":..,"y":..,"orientation":3,"style":5,"text":"GND",
"show_net_name":false}]. Harvest style/orientation from an existing
sheet rather than guessing: 5 = digital ground, 2 = supply bar.
notes: [{"x":..,"y":..,"text":".."}] free text.
All coordinates are mils and keep their fractions, so a metric sheet
can be drawn exactly (1 mm = 39.3700787 mil). The pin_map has the
same precision: route from its values unrounded, or a wire ends up
a few microns out of level and turns diagonal when its part moves.
Returns:
JSON with the created sheet name, counts, and the pin map - every
placed pin's true connection point, for routing a follow-up call.check_hierarchytool Check that a project's sheets are connected: every sheet entry against the
Check that a project's sheets are connected: every sheet entry against the
ports of its child sheet, harness types, and harness definitions.
Design >> Synchronize Sheet Entries and Ports does this for one sheet
symbol, by exact name. This covers the whole project at once, pairs that
probably belong together under different names, and the harness errors
the ERC reports without a location. It reads the SAVED files and does not
need Altium, so save first.
Issue types, by severity:
error
* probable_pair - an entry and a port that do not connect but belong
together (same harness type, same name apart from case/separators, or
a similar name). suggest renames the port to the entry's name, or the
entry when the child sheet is used by several sheet symbols;
alternative gives the other way round.
* harness_type_mismatch - entry and port of the same name with
different harness types.
* harness_conflict - one harness type defined with different entries on
two sheets (the ERC's fatal "Conflicting harness definition");
variants lists which entries only one side has.
* harness_type_undefined - an entry or port uses a harness type no
harness connector defines.
* signal_harness_untyped - a signal harness that reaches no harness
connector and no typed port or entry, with its location (the ERC's
fatal "Missing harness type on harness", which gives none).
* signal_harness_type_conflict - a signal harness joining two types.
* child_sheet_missing, sheet_symbol_without_file.
warning
* entry_without_port, port_without_entry - unmatched on one side.
linked_on_other_instance marks a port another sheet symbol using the
same child does link (the ERC is silent about this instance).
* io_mismatch, io_unspecified - I/O types of entry and port differ
(not for harness entries and ports, which have none in Altium).
* name_case, duplicate_entry, child_not_in_project.
* entry_unwired - nothing attached to the entry on the parent sheet.
* harness_file_stale, harness_file_missing - a <sheet>.Harness file
that disagrees with the sheet's harness connectors.
info
* entry_matches_power_port - no port for the entry, but a power port
of that name on the child sheet (power ports connect globally).
* harness_order, top_sheet_ports, sheet_not_in_hierarchy,
harness_file_not_in_project.
Locations are in mils, Altium's origin at the bottom left. Sheet symbols
are given by designator and location (symbol_at), since several symbols
may share a designator.
Args:
project: the .PrjPcb.
min_severity: "error", "warning" (default) or "info": the least severe
issues listed. Counts always cover every severity.
max_issues: cap on issues listed.
Returns:
JSON: settings, top sheets, issue counts by severity, and the issues.check_objects_drctool Run the board's design rules on chosen objects only, without a batchFilesoutside text
Run the board's design rules on chosen objects only, without a batch
DRC: the vias just moved, the tracks just added.
Each copper object is checked against its own width or hole-size rule,
and against every copper object near it (tracks, arcs, vias, pads,
fills, pour copper) for the clearance, short-circuit and hole-to-hole
rules. Objects on overlay, mask and mechanical layers are not checked.
The rule is the one Altium's DRC would pick for that object or pair,
and Rule.ActualCheck, the DRC's own test, decides the violation.
Pour copper is checked as it was last poured: a via moved into a pour
shows a violation against it until the pour is repoured
(repour_polygons). Those are listed apart, as pour_violations, and so
are hits on a hatched pour's tracks.
Args:
refs (list): Objects as "ref"s from objects_in_area (or pads as
"U1-3"); not a component or polygon as a whole: give its pads or
the regions it poured.
bbox (list): And/or [x1, y1, x2, y2] from the board origin: every
copper track, arc, via, pad and fill touching it (a ref in the
box is checked once).
unit (str): "mil" (default) or "mm".
limit (int): At most this many objects from the box (default 300).
margin (float): How far to look for neighbours, in unit. Default
twice the board's largest clearance or hole-to-hole gap plus
10 mil; raise it when a rule's per-object table (track to pad,
...) has a larger entry than its gap.
board_path (str): Full path of the .PcbDoc; default the focused board.
Returns:
str: JSON with objects_checked, pairs_checked, search_margin (how
far neighbours were looked for) and the violations: rule, kind,
both objects, their distance and the rule's gap;
pour_violations those against pour copper. When nothing was
checked (no ref found, nothing in the box) success is false.check_orientationtool Advisory check: find 2-pad passives whose rotation could be improved.Filesoutside text
Advisory check: find 2-pad passives whose rotation could be improved.
For each 2-pad component in the target set, every orthogonal rotation
(0/90/180/270) is scored in place, summing one term per pad:
- routable nets (few pads): the net's total airline (MST) length with
this pad at the candidate position - so a pad that merely slides along
a pass-through flow (e.g. a bulk cap in a power chain) scores as
nearly free, while a genuine detour costs its real length
- plane nets (many pads, e.g. GND): distance to the nearest same-net
pad - a capacitor's ground-return loop is local, so proximity to the
IC's GND/thermal pad is what matters
A component is reported when a different rotation beats the current one
by at least min_improvement_mils.
This is advisory, not pass/fail: it measures geometry only and knows
nothing about net criticality. Suggestions matter for loop-critical
parts (capacitor ground returns, snubbers, input/output filters) and
should usually be ignored for parts whose orientation is electrically
arbitrary (pull-ups, strapping resistors, enables) or where a datasheet
layout recommendation says otherwise. Weigh suggestions with judgement
rather than applying them blindly. If a suggestion with
bbox_changes=true is applied (a 90-degree change alters the body
outline), re-run check_placement afterwards.
Args:
cmp_designators (list, optional): Components to check. Omit to use
the current Altium selection. Components with more or fewer than
2 pads are skipped.
min_improvement_mils (float): Only report components where the best
rotation improves the connection score by at least this many
mils (default 25).
Returns:
str: JSON object with checked_count and suggestions, each having
designator, current_rotation, suggested_rotation,
improvement_mils, bbox_changes, and a per-pad breakdown of
nearest same-net distances at the current vs suggested rotation.check_placementtool Verify component placement: find overlaps and clearance violations.Filesoutside text
Verify component placement: find overlaps and clearance violations.
Checks each target component against every other component on the same
side of the board. Bounding boxes (which include silkscreen) are used as
a fast prefilter; close pairs are then measured precisely with Altium's
primitive-to-primitive distance, so reported distances are true minimum
distances between any primitives (pads, silk, etc.) of the two parts.
Run this after placing components - a screenshot is not verification.
Args:
cmp_designators (list, optional): Components to check (e.g. ["U12", "R42"]).
Omit to check the components currently selected in Altium.
clearance_mils (float): Minimum allowed primitive-to-primitive distance
in mils (default 6). Pairs closer than this are reported.
Returns:
str: JSON object with checked_count, violation_count, and a violations
list. Each violation has a/b designators, type
("bounding_box_overlap" = the parts' outlines intersect, or
"clearance" = distance below threshold), distance_mils (0 =
touching/overlapping copper or silk), overlap sizes when boxes
intersect, and the other part's x/y position. An empty violations
list means the placement is clean at the given clearance.check_routingtool Check the routed copper of the focused PCB for segments that are not 0,Filesoutside text
Check the routed copper of the focused PCB for segments that are not 0,
45 or 90 degrees, and for right-angle and acute corners.
Run this after changing tracks or vias - a screenshot does not show a
stub that is 2 degrees off 45. Such stubs come from a diagonal whose end
was snapped to a grid on its own, or from a track end dragged along
when a via or component moved. Only tracks with a net that are not part
of a component or polygon pour count. A corner is where exactly two
track ends of one net meet on one layer; under a via or pad it is not
a corner.
Args:
nets (list, optional): Check only these nets (exact names, any case).
angle_tolerance_deg (float): How far a segment may be from a
multiple of 45 degrees (default 0.1).
max_findings (int): Most entries listed per kind (default 50). The
counts always cover every segment.
Returns:
str: JSON with clean (true when nothing was found), the segment
count, segment_angles (orthogonal / 45 / off-angle counts),
corner_turns (straight / 45 / 90 / acute counts), and the
off_angle segments and sharp_corners: net, layer, positions in
mils relative to the board origin, angle or turn in degrees.check_silkscreentool Find the designators that need work. Start and finish silkscreen cleanupFilesoutside text
Find the designators that need work. Start and finish silkscreen cleanup
with this.
Two parts:
- drc: each designator is tested with Altium's own Silk To Silk
Clearance, Silk To Solder Mask Clearance and Board Outline Clearance
rules (Rule.ActualCheck, the test a batch DRC runs) against nearby
silk, pads, vias, mask objects and the board edge. Ground truth for
fabrication.
- quality: problems DRC does not flag - text far from its part or closer
to another part of the same type, over another part's body or under its
own (e.g. left on top of its part by an auto-placer), off the board, or
rotated to read upside down.
needs_attention lists every designator with either kind of problem;
hidden lists designators whose display is turned off.
Args:
designators (list, optional): Designators to check. Omit for all.
preview (bool): Also return a whole-board view with the problem
designators in red (default False).
Returns:
JSON with needs_attention, drc and quality (both grouped by
designator), hidden, plus optional view image(s).clearancetool Measure the gap between two board objects, and the clearance rule thatFilesoutside text
Measure the gap between two board objects, and the clearance rule that
governs them.
Args:
object_a (str): A "ref" from objects_in_area (any kind but polygon
and component), or a pad as "U1-3".
object_b (str): The other object, likewise.
unit (str): "mil" (default) or "mm".
board_path (str): Full path of the .PcbDoc; default the focused board.
Returns:
str: JSON with distance (edge to edge, 0 when they touch), rule,
rule_gap and violates_rule (Altium's own check of that rule
for this pair), and both objectscompare_netlisttool Compile the project and compare its netlist with a saved one: theFilesoutside text
Compile the project and compare its netlist with a saved one: the
safety net for editing sheets in place. Call it before an edit (the
first call only saves) and again after: it lists the nets that gained or
lost pins, the pins that moved between nets, nets added, removed or
renamed, and nets left with a single pin.
Snapshots are kept per project (by its full path, so a copy of a
project in another folder keeps its own) under a name. By default each
call compares with the previous call ("last") and then saves itself as
"last". Save a fixed baseline with save_as="before" and compare later
calls with against="before". The 20 most recently saved snapshots of a
project are kept; saving another removes the oldest (listed in
"pruned"). A snapshot that cannot be read as one is an error.
An auto-named net (NetR1_1) whose pins stay together under a new name is
a rename, not a removal and an addition. That matching is greedy: each
vanished net takes the new net it shares most pins with, in turn, so
when two vanished nets overlap the same new net only the first is a
rename. Compiling reads the sheets as they are open in Altium, unsaved
edits included.
Args:
project_path (str): Full path of the .PrjPcb; empty for the focused
project.
against (str): The snapshot to compare with; "" to only save.
save_as (str): Save this netlist under that name; "" to not save.
max_per_kind (int): At most this many entries per list.
Returns:
str: JSON with summary (count per kind of change), the changes, the
snapshot compared with (and when it was saved), the
unsaved sheets, and the snapshots pruned to make room.create_footprints_batchtool Create many PCB footprints in a single Altium script run.Filesoutside text
Create many PCB footprints in a single Altium script run.
The batch equivalent of create_pcb_footprint with far broader coverage:
through-hole and SMD pads (full pad stack, holes, slots, plating,
rotation), tracks, arcs, fills, texts, and regions on any layer.
Verified by exact round-trips of complete production footprint
libraries. Prefer this for bulk imports/migrations; use
get_footprint_primitives on an existing footprint to learn the exact
field conventions.
Args:
spec_file (str): Path to a plain-text spec file, one record per line
(coords in mils, layers as names, shapes/hole types as raw
Altium enum ints, booleans as 1/0):
FPLIB|<path to .PcbLib> (optional first line: opens/focuses)
FOOTPRINT|<name>|<description>
EDITFOOTPRINT|<name> add MODEL3D records to an existing
footprint (never creates one; other
records under it are reported and
ignored)
PAD|name|x|y|rot|layer|plated|hole_size|hole_type|hole_width|hole_rot|top_x|top_y|top_shape[|corner_pct[|mode|mid_x|mid_y|mid_shape|bot_x|bot_y|bot_shape[|paste_mode|paste_expansion|mask_mode|mask_expansion]]]
Leave a field empty to skip it and still give a later one.
paste_mode/mask_mode are TMaskExpansionMode ints: 1 rule,
2 manual (with the expansion in mils). 0 (no mask) cannot
be set on a pad by script and is reported as a problem.
Omitted: rule. Every pad the tool creates is locked.
TRACK|x1|y1|x2|y2|width|layer
ARC|cx|cy|radius|start_angle|end_angle|width|layer
FILL|x1|y1|x2|y2|rotation|layer
TEXT|x|y|size|width|rotation|layer|mirror|ttf|text
REGION|layer|kind|x1|y1|x2|y2|...
MODEL3D|<STEP file>|<layer>|<rot_x>|<rot_y>|<rot_z>|<z_offset>[|<x>|<y>[|<embed 1/0>]]
add a 3D body from a STEP file: rotations in degrees,
z_offset (model height above the board) and x|y (offset
from the footprint origin) in mils, embedded in the
library unless embed is 0. Read the result back with
get_footprint_primitives (bodies_3d); its rotations and
z offset appear only once the library is saved.
The library is left modified and unsaved; the user saves it.
Returns:
str: JSON with created and edited counts, models_added,
primitive_errors, failed names and problems (e.g. a missing
model file, mask mode 0, a record EDITFOOTPRINT ignores)create_net_classtool Create a new net class and add specified nets to itFilesoutside text
Create a new net class and add specified nets to it
Args:
class_name (str): Name of the net class to create or modify
net_names (list): List of net names to add to the class
Returns:
str: JSON object with the result of the operation. nets_added counts
the nets that were not in the class before; names the board has no
net for are listed in nets_not_found and not added.create_outjobtool Create a new .OutJob file, empty or as a copy of another OutJob.Filesoutside text
Create a new .OutJob file, empty or as a copy of another OutJob.
An output's settings are long and board specific, so the usual way to
get outputs is a template: one of your existing OutJobs (CAM, documents,
...). Then shape it with edit_outjob. An OutJob runs only from a
project: give project_path to add it to one (the project is opened in
Altium and saved; refused when it has unsaved changes there).
Args:
outjob_path (str): Full path of the new .OutJob; must not exist yet.
template_path (str): OutJob to copy; empty for an OutJob with only
the Print Job container.
project_path (str): .PrjPcb to add the new OutJob to.
Returns:
str: JSON with the containers and outputs of the new OutJob, and the
project it was added to.create_pcb_footprinttool Create a new PCB footprint in the currently active PcbLib document.Filesoutside text
Create a new PCB footprint in the currently active PcbLib document.
The PcbLib (e.g. Discrete.PcbLib) must be the focused document in Altium.
Pad format: each element is "pad_number|x_mm|y_mm|width_mm|height_mm|shape"
shape options: Rect (default), Round, Oval
Coordinates are in mm relative to component origin (0,0).
Pin 1 is indicated by a gap in the top-left silkscreen corner.
Pads are created locked.
Courtyard & silkscreen are auto-generated from pad extents + 0.25 mm margin
unless courtyard_x_mm / courtyard_y_mm are provided explicitly (half-dimensions).
The gap is always at the top-left corner of the outline, wherever pad 1
is, and the courtyard is always on Mechanical 15. For other conventions
use create_footprints_batch, which takes layers by name and any tracks.
Args:
footprint_name (str): Footprint name as it will appear in the library
description (str): Description string
pads (list): List of pad definitions, e.g. ["1|-0.9|0.55|1.0|0.8|Rect", ...]
courtyard_x_mm (float): Half-width of courtyard in mm (0 = auto)
courtyard_y_mm (float): Half-height of courtyard in mm (0 = auto)
Returns:
str: JSON object with resultcreate_pcb_ruletool Add a design rule to a PCB.Filesoutside text
Add a design rule to a PCB.
Values per rule_type, distances in mils:
clearance gap_mils (between scope1 and scope2)
width min_mils, max_mils, preferred_mils (all signal layers)
hole_size min_mils, max_mils
routing_via min/max/preferred_diameter_mils,
min/max/preferred_hole_mils
solder_mask_expansion expansion_mils (negative shrinks the opening)
paste_mask_expansion expansion_mils
polygon_connect connect_style ("relief", "direct", "none"), and
optionally conductor_width_mils, air_gap_mils,
entries (2 or 4)
Scopes are Altium query expressions, e.g. "All", "InNet('GND')",
"InNetClass('Power')", "IsVia", "HasFootprint('0402')". A one-scope
rule (width, hole size, via, mask, ...) uses scope1 only.
PRIORITY: Altium makes a rule added this way priority 1, the highest
of its kind, and moves the others down; a script cannot set priority.
So a new rule wins wherever its scope applies. Give it a narrow scope
(a net, class or object kind), or reorder priorities in Altium's PCB
Rules and Constraints Editor afterwards. get_pcb_rules lists all rules
with their priorities. Check the result's "descriptor": it is what
Altium stored.
Args:
rule_type (str): One of the kinds above.
name (str): Rule name, unique on the board.
values (dict): The values for that kind, e.g. {"gap_mils": 8}.
scope1 (str): First (or only) object scope.
scope2 (str): Second scope, for two-object rules such as clearance.
comment (str): Optional rule comment.
replace (bool): Replace an existing rule of the same name instead
of refusing.
board_path (str): Full path of the .PcbDoc; empty for the focused
board, or the one the PCB tools last used.
Returns:
str: JSON with the rule's name, descriptor, scopes, priority and
whether it replaced an existing rule.create_schematic_symboltool Before executing, run get_symbol_placement_rules first.Filesoutside text
Before executing, run get_symbol_placement_rules first.
For Altium API guidance while scripting, use the "altium-script" skill
(ensure_altium_script_skill reports whether it is installed).
Also look for a similar existing symbol to use as a style reference
before drawing: search a company/library .SchLib for a comparable part
(same category - op-amp, comparator, MCU, regulator, diode...) with
search_library_symbol, then dump it with get_symbol_primitives and
mirror its conventions (body style, pin lengths, pin name visibility,
grid spacing, glyph shapes). This produces symbols consistent with the
user's library. If no symbol library is available to reference, that is
fine - skip this step and proceed with the defaults below; do not treat
a missing reference as an error.
Create a new schematic symbol in the current library with the specified pins
Instructions: follow the rules from get_symbol_placement_rules and the
reference symbol's conventions; keep pins on a 100 mil grid
Pin name inversion/overbar: To show an overbar on a pin name (for active-low signals),
place a backslash after EACH character that should be overbarred.
Examples: R\E\S\E\T\ renders as RESET with overbar.
C\S\/A0 renders as CS with overbar followed by /A0 without overbar.
Do NOT use ~{...} or other notation — only the backslash-per-character format works in Altium.
Args:
symbol_name (str): Name of the symbol to create
description (str): Description of the schematic symbol
pins (list): List of pin data in format
"pin_number|pin_name|pin_type|pin_orientation|x|y[|owner_part_id[|length[|show_name[|show_designator]]]]"
Pin types: eElectricHiZ, eElectricInput, eElectricIO, eElectricOpenCollector,
eElectricOpenEmitter, eElectricOutput, eElectricPassive, eElectricPower
Pin orientations: eRotate0 (right), eRotate90 (up), eRotate180 (left), eRotate270 (down)
x, y is where the pin meets the body; the pin extends from there
in its orientation's direction (left-side pins eRotate180, top pins eRotate90)
X,Y coordinates in mils
owner_part_id (optional): Part number the pin belongs to (1-based).
Use 0 for pins shared across all parts (e.g. power/GND).
Defaults to 1 if omitted. Only needed for multi-part symbols.
length (optional): pin length in mils (default 300)
show_name / show_designator (optional): 1 or 0 to show/hide
the pin name / number (e.g. op-amp pins often hide names)
part_count (int): Number of parts in the symbol (default 1).
Use >1 for multi-part symbols like quad op-amps or hex buffers.
graphics (list, optional): Explicit body graphics. When given, the
default auto-sized body rectangle is NOT drawn - the
graphics fully define the symbol body (triangles for
op-amps, diode glyphs, etc.). Entry formats (coordinates
in mils; part = owner part id, 1-based; width 0-3 =
zero/small/medium/large; solid 1 or 0):
- "line|part|width|x1|y1|x2|y2"
- "polyline|part|width|x1|y1|x2|y2|..." (any number of vertices)
- "polygon|part|width|solid|x1|y1|x2|y2|..." (closed/filled shape)
- "rectangle|part|width|solid|x1|y1|x2|y2"
- "arc|part|width|cx|cy|radius|start_angle|end_angle" (degrees CCW from 3 o'clock)
- "elliptical_arc|part|width|cx|cy|radius|secondary_radius|start_angle|end_angle"
- "ellipse|part|width|solid|cx|cy|radius|secondary_radius"
- "label|part|x|y|text" (free text annotation)
Tip: to reproduce an existing symbol's style, dump it first
with get_symbol_primitives and mirror its primitives.
Returns:
str: JSON object with the result of the component creationdelete_pcb_objectstool Delete copper from a PCB: tracks, arcs, vias, polygon pours, copperFilesoutside text
Delete copper from a PCB: tracks, arcs, vias, polygon pours, copper
regions, fills or pour cutouts. Use it to rip up routing.
Objects are picked by every filter given: kinds, net, layer and area,
or a group's copper by designators. At least one must narrow the match;
deleting all the copper on the board is refused. Only copper is ever
touched: never pads, anything belonging to a component, keepouts, or
objects on other layers (board outline, silkscreen, mechanical). The
copper a pour poured goes with its pour. Locked objects are left alone
and listed, unless include_locked. One undo step in Altium. Use dry_run
first to see what would go.
Deleting copper inside a pour leaves the pour as it was: repour it.
Remove a via stitching group with Altium's own command rather than
here, so the group goes too.
Args:
kinds (list): Some of "track", "arc", "via", "polygon", "region",
"fill", "cutout" (a pour cutout). Empty: all but cutouts.
net (str): Only objects on this net.
layer (str): Only objects on this copper layer, by stack name or
Altium's name ("Top Layer"); a via matches every layer it spans.
area (list): [x1, y1, x2, y2] in mils from the board origin; only
objects lying inside it.
designators (list): Rip up a group's copper, as get_layout lists it:
what lies inside the group's extent (grown by margin_mils, or
area when given) plus the copper of its own nets (nets with no
pad on another part) wherever it runs.
margin_mils (float): See designators (default 40).
include_locked (bool): Delete locked objects too.
dry_run (bool): List what matches without deleting.
board_path (str): Full path of the .PcbDoc; empty for the focused
board, or the one the PCB tools last used.
Returns:
str: JSON with matched, deleted, the first 50 objects (kind, net,
layer, position in mils), and locked_skipped with the first
20 locked objects left alone.dismiss_dialogtool Close an open Altium dialog, such as one left over a board that keeps
Close an open Altium dialog, such as one left over a board that keeps
get_screenshot from capturing it, as its close box does: whatever it
asks about is left unapplied. Only Altium's own dialogs, as
get_altium_windows lists them: never its main window, a panel or a
window of another program.
No button is ever pressed: a button commits what the dialog asks about
(Save changes? No, Project Options OK, Execute Changes), and a dialog an
agent opened cannot be told from one the user is filling in.
Args:
dialog (str | int): The dialog's hwnd (from get_altium_windows) or its title
Returns:
str: JSON with closed (the dialog went away), its class and titledrag_coppertool Move a via or a track segment and keep it connected: track ends thatFilesoutside text
Move a via or a track segment and keep it connected: track ends that
meet it follow (they stretch), and a via at an end of a moved track
moves with it, its tracks on the other layers following too.
Refused when an arc ends at a moved point or a pad lies under one,
since those cannot follow; when copper of the same net meets moving copper
partway along a track (a T-junction: a branch ending partway along a moved
track, a moved end landing partway along another track, a track running
through a dragged via), since it would be left unconnected; and when any
of the copper to move or stretch is locked. The blocker names the copper.
dry_run shows what would move first. Polygon
pours are not repoured: run repour_polygons afterwards if copper changed
near one, and check_routing to confirm the connections.
Args:
object_ref (str): A via or track "ref" from objects_in_area.
dx (float): Move along x, in unit.
dy (float): Move along y, in unit.
unit (str): "mil" (default) or "mm".
dry_run (bool): Report what would move and stretch; change nothing.
board_path (str): Full path of the .PcbDoc; default the focused board.
Returns:
str: JSON with moved (the object, and vias moved with it), stretched
(track ends that followed), blocker (why it cannot be dragged)edit_outjobtool Change an .OutJob: its containers, which outputs it has and where they go.Filesoutside text
Change an .OutJob: its containers, which outputs it has and where they go.
Operations run in order. One that fails is reported in "errors" and
the rest still run, but then nothing is written: the file changes only
when every operation succeeded. The file is edited in place, keeping
everything not changed as Altium wrote it. If the OutJob is open in
Altium it is closed first and opened again after, also when the write
fails (refused when it has unsaved changes there). Altium is not started
when it is not running.
Operations, each a dict with "op":
add_container name, type ("generated_files" or "pdf"), [folder]
(relative to the project, e.g. "Fab"),
[file_name] (pdf), [open_outputs] (default false:
the files are not opened after each run). Other
settings are copied from a container of the same
type, but not its folder or file name; a second PDF
container needs a folder or file_name.
set_container name, [new_name], [folder], [file_name], [open_outputs]
remove_container name
copy_output output (name or number), [from_outjob] (another
.OutJob; this one if left out), [new_name],
[containers] (names to put it in)
remove_output output
set_output output, [new_name], [enabled], [document_path],
[containers] ({container name: true/false}, or
a list of names to put it in)
set_output_setting output, key, value: one setting inside the output's
configuration, e.g. key "GerberUnit" value "Metric".
The key must already be there; get_outjob_settings
with include_raw_settings shows them.
Run with run_output_jobs; check with get_outjob_settings.
Args:
outjob_path (str): Full path of the .OutJob.
operations (list): The operations, as above.
dry_run (bool): Report what would change without writing.
Returns:
str: JSON with what was done, errors, and the containers and outputs
after the edit.edit_schematictool Change an existing schematic sheet: move, rotate, delete or place parts,Filesoutside text
Change an existing schematic sheet: move, rotate, delete or place parts,
set parameters, move designators and parameter text, add wires, net
labels, power ports, junctions and no-ERC markers, and delete objects.
The whole edit is one undo step in Altium (Ctrl+Z takes it all back),
and the user's own edits stay undoable. Operations run in order; one
that fails is reported in "errors" and the rest still run.
Coordinates are absolute sheet coordinates, Altium's origin at the
bottom left, in `unit` ("mil" or "mm"). check_schematic reports
positions and suggestions in the sheet's own unit (mm for a metric
grid), so pass the same unit to apply its suggestions directly.
Operations, each a dict with "op":
move_component designator, [part], [x, y], [rotation 0/90/180/270],
[mirror true/false]. x, y is the part's origin.
delete_component designator, [part]
place_component library (.SchLib path), symbol, designator, x, y,
[rotation], [mirror], [comment]. For a part from a
database library, dblib (.DbLib path) and
part_number (its key), [table], in place of library
and symbol: the row gives the symbol, footprints,
description and parameters, and the part is linked
to the DbLib as when Altium places it (Excel tables)
set_parameter designator, name, value, [part], [visible]
(creates the parameter when missing)
move_text designator, name ("Designator", "Comment" or a
parameter), [part], [x, y], [justification 0-8:
bottom-left, bottom-centre, bottom-right, middle-left,
..., top-right], [orientation 0-3], [visible]
add_wire points [[x, y] or "U20.VCC", ...]: a point may name
a pin, by number ("U20.3") or name ("U20.VCC")
add_net_label x, y (on a wire), text, [orientation], [justification]
add_power_port x, y, text, [style: bar, arrow, circle, wave,
power_ground, signal_ground, earth], [orientation
0-3, default 1 = up], [show_net_name]
add_junction x, y
add_no_erc x, y
add_port x, y (its left end, or bottom end when vertical),
name, [io_type: unspecified, output, input,
bidirectional], [style: right (default), left,
left_right, none, and vertical: top, bottom,
top_bottom, none_vertical], [width]:
a width turns auto size off, so the port keeps its
length and stays on its wire when renamed
edit_sheet_symbol sheet (its sheet name, or file name if unique),
[x, y] (top left; entries and texts move along),
[width, height], [fill_color, border_color]
("#RRGGBB"), [line_width smallest/small/medium/
large], [name_x, name_y], [file_x, file_y] (where
the sheet name and file name texts sit). A size
that would leave an entry outside is refused; on a
resize the right and bottom entries move with their
edge (wires to them are not dragged)
edit_sheet_entry sheet, name, [side left/right/top/bottom],
[distance] (from the symbol's top edge on the left
and right sides, from its left edge on the top and
bottom), [io_type], [style, as add_port], [new_name]
move_wire_vertex x, y, to_x, to_y: moves the vertex at x, y of every
wire with one there (an end or a corner), so wires
that meet there stay joined; junctions, net labels
and power ports at x, y, and ports with an end
there, move with it; also to trim a wire. Refused
when a wire passes through x, y mid-segment (a T
connection)
move_net_label x, y (the label's location), [text], [to_x, to_y],
[orientation], [justification],
[snap_to_wire_end] (true, or a search radius in
unit: puts the label on the nearest wire end to its
target, 100 mil by default)
delete_at kind (wire, net_label, power_port, junction, no_erc,
port, note), x, y, [text]: removes a wire passing
through the point, or the object located there
"part" picks one part of a multi-part component (1 = A, ...).
The add_* operations with x, y also take "at": "U20.VCC" instead, to
place a label, port, power port, junction or no-ERC on a pin. Pins are
read live from the sheet (see get_schematic_pins) before anything is
changed; an unknown pin or a name several pins share is an error. So a
reference to a part that an earlier operation in the same call moves,
places or deletes is refused: refer to it in a second call. On a
multi-part part, "U1A.3" names pin 3 of part A; a pin common to every
part (often the power pins) needs the part letter.
Args:
sheet_path (str): Full path of the .SchDoc; opened if not open.
operations (list): The operations above, applied in order.
unit (str): "mil" (default) or "mm".
save (bool): Save the sheet afterwards (needed before
check_schematic, which reads the saved file). Otherwise it is
left modified for the user to review and save.
Returns:
str: JSON with how many operations were applied and the errors.ensure_altium_script_skilltool Check whether the "altium-script" skill is installed, and optionallyProcesses
Check whether the "altium-script" skill is installed, and optionally
install it.
That skill documents the Altium DelphiScript API - interfaces, object
models, worked examples, conventions, and how to discover undocumented
processes - and is the reference to consult before writing scripts for
run_altium_script or debugging Altium API calls.
Source: https://github.com/coffeenmusic/altium-scripts-skill
Installing writes into the user's skills directory, so it only happens when
install=True is passed explicitly. Skills load at client startup, so a
newly installed skill becomes available after restarting the client.
Args:
install (bool): Install the skill if missing (requires git on PATH).
Returns:
str: JSON with installed (bool), the path checked, and the next step.fanout_padstool Fan out pads: a short track from each pad to a via next to it, e.g. toFilesoutside text
Fan out pads: a short track from each pad to a via next to it, e.g. to
take an IC's ground and power pads down to their planes, or to free a
pad for routing on another layer. Each via goes outward from the
component first (then the other 45 degree directions), as near as
clearance_mils from other nets' copper allows, within max_distance_mils.
Pads that already have a track or via on them are left alone. One undo
step; vias are through (Top to Bottom).
Args:
designators (list): Components whose pads to fan out.
nets (list): Only pads on these nets, e.g. ["GND", "3V3"].
pads (list): Only these pads, as "U1-5" or pad names.
width_mils, clearance_mils (float): Track width and gap to other
nets' copper. By default each net's width rule (its preferred
width, but no wider than the pad and never below the rule's
minimum) and the largest clearance rule gap of the nets.
via_diameter_mils, via_hole_mils (float): Via size.
max_distance_mils (float): Farthest a via may sit from its pad's
centre (default 80).
grid_mils (float): Grid for the clearance check (default 2.5).
dry_run (bool): Return the vias and tracks without adding them.
board_path (str): Full path of the .PcbDoc; empty for the focused
board, or the one the PCB tools last used.
Returns:
JSON: fanned out pads with their via positions, pads skipped (and
why), and the counts added.get_all_component_property_namestool Get all available component property names (JSON keys) from all componentsFilesoutside text
Get all available component property names (JSON keys) from all components
Returns:
str: JSON array with all unique property namesget_all_designatorstool Get all component designators from the current Altium boardFilesoutside text
Get all component designators from the current Altium board
Returns:
str: JSON array of all component designators on the current boardget_all_netstool Return every unique net name in the active PCB document.Filesoutside text
Return every unique net name in the active PCB document.
Returns
-------
str :
A JSON array of net names, e.g. ["GND", "VCC33", "USB_D+", ...]get_altium_windowstool List Altium's own dialogs and floating panels: the windows that can lie
List Altium's own dialogs and floating panels: the windows that can lie
over a board and end up in a screenshot, or keep Altium waiting.
Returns:
str: JSON with windows [{hwnd, class, title, rect, kind, modal}],
topmost first. kind is "dialog" or "panel" (a floating panel);
modal says the dialog blocks Altium until it is closed (see
dismiss_dialog).get_board_summarytool Summarise the focused PCB for fabrication checks.Filesoutside text
Summarise the focused PCB for fabrication checks.
Read-only. Coordinates are millimetres relative to the board origin.
Returns:
str: JSON with pcb_path, board origin (absolute), board_outline
(bounding box, width, height, vertex count), dimensions (cotas)
with their extents, via_count and vias_by_hole, components per
side, layer_contents (primitive count per layer, split into free
objects and objects inside components) and overlay_texts (free
texts on Top/Bottom Overlay, e.g. board name and revision)get_component_datatool Get all data for components in AltiumFilesoutside text
Get all data for components in Altium
Args:
cmp_designators (list): List of designators of the components (e.g., ["R1", "C5", "U3"])
Returns:
str: JSON object with all component data for requested designatorsget_component_pinstool Get pin data for components in AltiumFilesoutside text
Get pin data for components in Altium
Args:
cmp_designators (list): List of designators of the components (e.g., ["R1", "C5", "U3"])
Returns:
str: JSON array, one entry per component with its placement info
(x/y in mils relative to the board origin, rotation in degrees
counterclockwise, layer) and a "pins" list. Per pin:
- x/y: absolute pad position (mils, relative to board origin)
- dx/dy: pad offset from the component origin in the footprint's
rotation-0 frame. To predict a pad position for a planned
placement: mirror dx (dx = -dx) if placing on the bottom layer,
rotate (dx, dy) counterclockwise by the planned rotation, then
add the planned component x/y.
- rotation: the pad's own rotation (NOT the component rotation)
- net, layer, width, height, shapeget_component_primitivestool List the primitives of PCB components with the layer each one is on.Filesoutside text
List the primitives of PCB components with the layer each one is on.
Read-only. Useful to check footprints that were flipped to the bottom
side (e.g. fiducials: the copper and the pad that opens the solder mask
must end up on the same layer) and pad mask expansions.
Args:
designators (list): Component designators, e.g. ["FD1", "FD3"]
Returns:
str: JSON with components [{designator, footprint, layer, x_mm, y_mm,
rotation, primitives [{type, layer, ...}]}] and
missing_designatorsget_component_property_valuestool Get values of a specific property for all componentsFilesoutside text
Get values of a specific property for all components
Args:
property_name (str): The name of the property to get values for
Returns:
str: JSON array with objects containing designator and property valueget_designator_optionstool Legal spots for designators, ranked, drawn as numbered boxes.Filesoutside text
Legal spots for designators, ranked, drawn as numbered boxes.
For each designator: its current spot and what is wrong with it, then up
to `count` distinct legal positions around its part - clear of silk, solder
mask openings, untented vias, the board edge and every other designator
where it is now, readable, and nearer its own part than any other part of
the same type. Ranked by: close to the part, above > left/right > below,
text along the part's long axis, centred. Pick one (or use the image to
judge a better spot) and apply it with set_designator_positions using the
option's x, y and rotation.
The designators asked about are not obstacles to each other: when placing
neighbours, check the chosen spots together with
set_designator_positions(dry_run=True) first. When a designator has no
legal spot, blocked_by says what is in the way: ask again together with
the neighbouring designators (so they can move to make room), allow
smaller text (min_height_mils), or place its row's designators as a
block with get_label_block_options. Do not hide designators to get rid
of problems; only mounting holes and fiducials go without one.
Args:
designators (list): Designators to find spots for.
count (int): Options per designator (default 5).
max_gap_mils (float): Furthest the text may sit from its part's pads
and silk (default 50).
min_height_mils (float): Also offer smaller text, down to this height,
in 5 mil steps (0 = current size only).
refresh (bool): Re-export the board from Altium first.
Returns:
JSON per designator (current spot + problems, options with n, x, y,
rotation, side, gap_mils and height when reduced, or blocked_by) plus
an image per board side with the options numbered.get_erc_violationstool Compile a project and list its ERC/compiler violations.Filesoutside text
Compile a project and list its ERC/compiler violations.
Give project_path to compile exactly that project (it is opened if
needed): without it the focused project is compiled, which is whatever
document last had focus, and "Free Documents" is refused. The result
names the project it compiled.
Compiling reads each sheet from disk, except a sheet open in Altium with
unsaved changes: that one is compiled from Altium's copy and listed in
unsaved_in_altium. Save it (or close it unsaved) for the file to count.
Sheets the project lists but that are not on disk are in
missing_on_disk. Compiling does not save any document (Altium may
refresh the derived .PrjPcbStructure file).
Args:
compile (bool): Compile before reading (default True). False returns
the violations of the last compilation.
project_path (str): Full path of the .PrjPcb to compile.
Returns:
str: JSON with project_path, unsaved_in_altium, missing_on_disk,
total, fatal, errors, warnings and violations
[{level, type, detail}]get_footprint_primitivestool Read the primitives of footprints in a PCB library (.PcbLib).ProcessesFilesoutside text
Read the primitives of footprints in a PCB library (.PcbLib).
Modes:
- footprint_name omitted: inventory of every footprint with per-type
primitive counts (pads, tracks, arcs, fills, texts, regions, vias,
component_bodies)
- footprint_name given (exact, case-insensitive): full geometry dump -
pads (position, rotation, layer, sizes/shape per stack, hole size/
type/width/rotation, plating, paste_mode/paste_expansion,
mask_mode/mask_expansion, locked), tracks, arcs, fills, texts,
regions (outline vertices). Coordinates in mils relative to the
footprint origin (also for the footprint shown in the editor, which
Altium holds offset by the library origin); shapes and hole types as
raw Altium enum ints; layers as names. 3D component bodies are listed
apart in bodies_3d, not among the primitives, so the
create_footprints_batch round-trip is unchanged: model_file,
model_embedded, model_x/model_y (offset from the footprint origin),
standoff_height and overall_height (mils), layer, and
rotation_x/y/z (degrees) and model_z_offset (mils). The rotations and
offset come from the saved library file (Altium's script API cannot
return them); "placement" says so, and they are null for a body that
is not saved yet.
- footprint_name "*": full dump of every footprint
Use as the reference when recreating or validating footprints, and to
survey what a library requires.
Args:
library_path (str, optional): Full path to the .PcbLib. Omit to use
the currently focused PCB library (an already-open library is
only focused, never reloaded).
footprint_name (str, optional): Exact footprint name, or "*".
Returns:
str: JSON - inventory: {library_name, footprint_count, footprints:
[{name, description, <type counts>}]}; dump: primitives and
bodies_3d per footprintget_label_block_optionstool Place a row of parts' designators together as a block, when they do notFilesoutside text
Place a row of parts' designators together as a block, when they do not
fit next to their parts one by one. Use this instead of hiding
designators (only mounting holes and fiducials go without one).
Parts in a row get their designators in a row too, in the same order,
even some way off. Give one designator to use the whole row it belongs
to (parts side by side along x or y, similar size across the row, gaps
up to 50 mil), or list the parts yourself. For a block of just one part
(its label alone, linked to it), give it with whole_row=False.
Each option is a block of labels - across the row (in line with each
part when the pitch allows, else side by side) or end to end along it -
clear of silk, mask openings, the board edge, other designators and part
bodies, plus a link when it is not right against the row:
- leader: a silk line with an arrowhead from the block to the parts;
- index: matching markers - a capital letter in a circle (then square,
then triangle) - next to the block and next to the parts.
Ranked: no link, then leader, then index; nearer and larger text first.
Apply one with place_label_block.
Args:
designators (list): One designator (its row is used) or the block's parts.
count (int): Options to return (default 3).
min_height_mils (float): Smallest text allowed (default 25).
max_distance_mils (float): Furthest the block may sit from the parts (default 500).
link (str): "auto" (cheapest), "none", "leader" or "index".
whole_row (bool): With one designator, use its whole row (default)
or just that part.
refresh (bool): Re-export the board from Altium first.
Returns:
JSON with the parts in order and the numbered options, plus an image
per option (block labels cyan with lines to their parts, link magenta).get_layouttool Read the layout of a group of components or of an area: the components'Filesoutside text
Read the layout of a group of components or of an area: the components'
placement and the copper around them (tracks, arcs, vias, fills, copper
regions and polygon pours, each pour with its full outline, arc edges
included, and its pour settings). Read-only.
The result is in exactly the form place_copper takes, so it can be
edited and placed again, on this board or moved with place_copper's
transform (to repeat a channel, for example). The components come in
place_components' form.
Args:
designators (list): Components to read, e.g. ["U5", "C13", "Y1"].
Without an area, the area is their extent (pads and bodies)
grown by margin_mils.
area (list): [x1, y1, x2, y2] in mils from the board origin. With
no designators, the components wholly inside it are listed.
margin_mils (float): How far the area reaches beyond the components
(default 40).
include_touching (bool): Also list copper that only reaches into the
area, such as a track leaving the group. By default only copper
wholly inside the area is listed: the group's own routing.
include_local_nets (bool): With designators, also list the copper of
their own nets (nets with no pad on any other part) wherever it
runs, such as a route between two of them that leaves the area
(default true).
include_pads (bool): Also list every pad reaching into the area
(designator, pad, x, y, layer, shape, size [x, y], rotation,
hole, net), e.g. to see what new copper must keep clear of.
board_path (str): Full path of the .PcbDoc; empty for the focused
board, or the one the PCB tools last used.
out_file (str): Write the layout to this JSON file and return only a
summary; for large areas.
Never listed: copper that belongs to a component or that a pour poured
(the pour itself is), keepouts, and objects on non-copper layers
(counted in skipped).
To see everything in a box, on any layer and with refs that clearance
and drag_copper take, use objects_in_area instead; get_layout is for
reading copper to edit and place again.
Returns:
JSON: area; components (designator, x, y, rotation, layer, locked,
footprint, designator_text and comment_text: {x, y, rotation,
height, stroke_width, visible, autoposition}); tracks (net, layer,
width, start, end); arcs (net, layer, width, center, radius,
start_angle, end_angle: counter-clockwise from start to end); vias
(net, x, y, diameter, hole, start_layer, end_layer); fills; regions;
cutouts (layer, outline); pours (name, net, layer, hatch, pour_over,
remove_dead_copper, remove_islands, island_area_sq_mils,
remove_necks, neck_width_mils, grid, track_width, arc_approximation,
pour_index, locked, obey_cutouts, optimal_void_rotation, outline:
vertices {x, y} with "arc" {center, radius, start_angle, end_angle}
when the edge to the next vertex is an arc); counts and
missing_designators. All in mils and degrees.get_library_symbol_referencetool Get the currently open symbol from a schematic library to use as reference for creating a new symbol.Filesoutside text
Get the currently open symbol from a schematic library to use as reference for creating a new symbol.
This tool should be used before creating a new symbol to understand the structure of existing symbols.
Returns:
str: JSON object with the reference symbol data including pins, their types, positions, and orientationsget_net_connectionstool Get net connectivity and airline (unrouted connection) lengths for theFilesoutside text
Get net connectivity and airline (unrouted connection) lengths for the
nets touching the given components.
Use this to plan or score a placement: it shows every pad on each net -
including pads of OTHER components outside the given set (e.g. an input
filter the cluster must connect to) - plus the net's minimum-spanning-tree
airline length in mils. Shorter airlines on critical nets (switching
loops, input/output capacitors) mean a better placement; non-critical
nets (enables, set resistors, feedback dividers) may be lengthened to
buy routing space. Plane nets like GND have many pads and a meaningless
airline - judge them by proximity to plane connections instead.
Args:
cmp_designators (list, optional): Components whose nets to analyze
(e.g. ["U12", "R42"]). Omit to use the current Altium selection.
max_pads_per_net (int): Nets with more pads than this (e.g. GND)
return only pads belonging to the given components, plus the
total pad_count. Their airline is also skipped. Default 40.
Returns:
str: JSON object with one entry per net: pad_count,
airline_mst_mils (None for large nets), and pads
[{designator, pin, x, y}, ...] in mils relative to the board
origin. Large nets set pads_truncated=true.get_output_job_containerstool Get all available output job containers from a specified OutJob fileFilesoutside text
Get all available output job containers from a specified OutJob file
Args:
outjob_path (str): Full path to the OutJob file (optional). When empty,
the first OutJob found in the open projects is used, in project
order, regardless of which document has focus.
Returns:
str: JSON with outjob_path (the file actually used) and the containersget_pcb_layer_stackuptool Get the detailed layer stackup information from the current Altium PCB includingFilesoutside text
Get the detailed layer stackup information from the current Altium PCB including
copper thickness, dielectric materials, constants, and heights
Returns:
str: JSON object with detailed layer stackup informationget_pcb_layerstool Get detailed information about all layers in the current Altium PCBFilesoutside text
Get detailed information about all layers in the current Altium PCB
Returns:
str: JSON object with detailed layer information including copper layers,
mechanical layers, and special layers with their propertiesget_pcb_rulestool Get all design rules from the current Altium PCBFilesoutside text
Get all design rules from the current Altium PCB
Returns:
str: JSON array of PCB design rules: name, enabled, priority (1 is
the highest within a rule kind), descriptor, rule_kind and the
two scope expressions (filter1, filter2)get_pour_reporttool Check what polygon pours poured: islands, slivers, and pours with no netFilesoutside text
Check what polygon pours poured: islands, slivers, and pours with no net
or no copper. Read only; repour first (repour_polygons) to check the
copper as the rules now make it.
Each polygon is listed with its pieces of solid copper and their sizes,
and flags:
* islands - poured into more than one separate piece;
* slivers - a piece smaller than sliver_sq_mils;
* no_net - the polygon has no net (dead copper);
* no_copper - poured nothing (no room, or all removed as dead copper);
* shelved - shelved, so it has no copper now.
A piece's area is its outline, holes not subtracted: an upper bound.
Args:
names, net, layer, area: Filters, as for repour_polygons; with none,
every polygon on the board.
sliver_sq_mils (float): A piece below this area is a sliver
(default 100 sq mil).
board_path (str): Full path of the .PcbDoc; empty for the focused
board, or the one the PCB tools last used.
Returns:
str: JSON with each polygon (name, layer, net, pieces, smallest
piece, copper area, slivers, flags) and the flagged ones first.get_project_componentstool List the components of the compiled project (schematic side).Filesoutside text
List the components of the compiled project (schematic side).
Compiles the project in memory first (nothing is saved): project_path,
or the focused project, as for get_erc_violations. Unlike
the PCB component tools, this returns the schematic Comment of each
instance, which is where values of generic passives usually live.
A large project does not fit in one reply. A reply stops at about 60,000
characters: when next_offset is not null, call again with
offset=next_offset and the same filters for the rest. Filter first when
you can: all parameters of every part can come to megabytes.
Args:
include_parameters (bool): Also return every component parameter
(e.g. Manufacturer_Part_Number). Default False - the output is
much larger with parameters.
designators (list): Only these designators. Wildcards work and case
does not matter, e.g. ["R*", "U1", "C1?"].
sheet (str): Only this sheet, by file name ("Power.SchDoc");
wildcards work.
offset (int): Skip this many matching components.
limit (int): At most this many components; 0 for as many as fit.
parameter_names (list): Return only these parameters, e.g.
["Manufacturer_Part_Number"]. Implies include_parameters.
project_path (str): Full path of the .PrjPcb to compile.
Returns:
str: JSON with project_path, component_count (the whole project),
matched, offset, returned, next_offset and components
[{designator, comment, footprint, library_reference, sheet,
parameters?}]get_project_infotool Get the focused Altium project: parameters, documents and variants.Filesoutside text
Get the focused Altium project: parameters, documents and variants.
Read-only. Use it to check that nothing has unsaved changes before
generating outputs, and to read project parameters and variants.
Returns:
str: JSON with project_path, parameters [{name, value}],
schematic_sheet_count, modified_document_count, documents
[{path, kind, state}] where state is "closed", "open" or
"modified" (unsaved changes in memory), and variants
[{name, variations [{designator, kind}]}] where kind is
"not_fitted" or "alternate"get_schematic_datatool Get schematic data for components in AltiumFilesoutside text
Get schematic data for components in Altium
Args:
cmp_designators (list): List of designators of the components (e.g., ["R1", "C5", "U3"])
Returns:
str: JSON object with schematic component data for requested designatorsget_schematic_pinstool The pins of a schematic sheet's parts, live from Altium: each pin'sFilesoutside text
The pins of a schematic sheet's parts, live from Altium: each pin's
connection point (the outer end, where a wire must end), number, name,
electrical type and whether it is hidden. Only the part and display mode
each component shows are listed. Unsaved changes in Altium are seen.
Args:
sheet_path (str): Full path of the .SchDoc; opened if not open.
designators (list): Only these components; empty for all.
unit (str): "mil" (default) or "mm" for the coordinates.
Returns:
str: JSON with the pins: designator, part, pin, name, x, y,
electrical, hidden.get_screenshottool Take a screenshot of exactly one thing in Altium, returned as viewable image content.FilesEnv varsoutside text
Take a screenshot of exactly one thing in Altium, returned as viewable image content.
Say what to capture with `target`:
"current" the Altium window as it is now (the default).
Nothing is switched or opened.
"document" the editing area of the active document only.
"document:<name>" the editing area of that document: a file name
("PD_Mon.SchDoc") or a full path. It must already
be open unless open_if_closed is true. The document
that was active before is brought back afterwards,
and one opened for the capture is closed again
(only when it has no unsaved changes).
"dialog" the topmost Altium dialog or popup menu.
"panel:<name>" one panel, e.g. "panel:Projects", "panel:Components".
"region:x,y,w,h" a rectangle inside Altium's main window, in
pixels of a "current" capture (0,0 = its top
left corner). A region reaching outside the
window is refused: nothing outside Altium is
ever captured.
Altium comes to the front for about a second, because it only paints what
is on screen; the window that was in front then gets the foreground back.
Altium's own windows over a "current", "document" or "region" capture
are checked too: with one of its dialogs over the area nothing is
captured and the error names the dialog (see get_altium_windows and
dismiss_dialog). A floating panel there (Messages, after run_drc) gives
a warning, or is hidden for the capture with hide_floating_panels.
Args:
target (str): What to capture, see above. Default "current".
view_type (str): Old form, kept for compatibility: 'pcb' or 'sch' brings
some document of that kind to the front (opening one if none is
open) and captures the whole window. Ignored when target is given.
zoom_to (list, optional): Component designators (e.g. ["U12", "R42"]).
PCB only: Altium zooms to them before the capture. Works with
"document" / "document:<board>" and view_type 'pcb'; given on its
own it means view_type 'pcb'. "board" instead fits the whole
board outline in the view (with "document" / "document:<board>";
on its own it means target "document").
open_if_closed (bool): Let "document:<name>" open a document of the
open projects that is not open yet. Default false.
hide_floating_panels (bool): Hide Altium's floating panels that lie
over the capture while it is taken, and show them again after.
Default false: they stay, and "warnings" says how much they cover.
hide_hud (bool): Move the mouse pointer off the document view for
the capture, and back after, when it is over it: Altium draws its
heads-up coordinate display by the pointer. Default false: it
moves the user's real pointer, so only turn it on when nobody is
using the mouse.
Returns:
JSON metadata (what was captured: target, rectangle, captured_kind,
captured_document, view_type, whether anything was switched, opened or
closed, warnings, and saved_path: the PNG as a file in the server's
own folder, where the newest 50 captures are kept; copy it to use
the image elsewhere) plus the PNG image.get_selected_components_coordinatestool Get coordinates and positioning information for selected components in Altium layoutFilesoutside text
Get coordinates and positioning information for selected components in Altium layout
Returns:
str: JSON array with positioning data (designator, x, y, rotation, width, height)get_server_statustool Get the current status of the Altium MCP serverFilesoutside text
Get the current status of the Altium MCP server
get_symbol_placement_rulestool Get schematic symbol placement rules from a local configuration fileFilesoutside text
Get schematic symbol placement rules from a local configuration file
Returns:
str: JSON object with rules for placing pins on schematic symbolsget_symbol_primitivestool Read the graphic primitives of symbols in a schematic library (.SchLib).Filesoutside text
Read the graphic primitives of symbols in a schematic library (.SchLib).
Two modes:
- symbol_name omitted: inventory of every symbol in the library with
per-type primitive counts (pins, rectangles, lines, polylines,
polygons, arcs, ellipses, beziers, labels, ...). Use this to survey
what drawing features a library's symbols require.
- symbol_name given (exact match, case-insensitive): full geometry dump
of that symbol - every primitive with coordinates in mils, plus pin
details (number, name, electrical type, orientation, length,
owner_part_id). Use this as the reference/spec when recreating or
validating a symbol.
Args:
library_path (str, optional): Full path to the .SchLib file to open.
Omit to use the schematic library currently focused in Altium.
symbol_name (str, optional): Exact symbol (LibReference) name to dump.
Returns:
str: JSON object - inventory mode: {library_name, symbol_count,
symbols: [{name, description, part_count, <type counts>}]};
dump mode: {library_name, symbol_name, description, part_count,
comment: {text, visible}, parameters: [{name, value, visible,
x, y, justification, autoposition, font: {name, size}}],
primitives: [...]} - x and y are where Altium holds the
parameter now. Pins also carry
description, symbol_inside, symbol_inside_edge,
symbol_outside_edge and symbol_outside (IEEE symbol names as
PINSYMBOL takes them), their parameters [{name, value}]
when they have any, and functions ["ETH1_MDIO", ...] (the
Functions list, as PINFUNC sets it) when they have anyget_unrouted_connectionstool List the connections still to be routed (Altium's ratsnest lines): for aFilesoutside text
List the connections still to be routed (Altium's ratsnest lines): for a
group of components, some nets, or the whole board. Unlike run_drc it
has no 500-violation limit and needs no DRC run, so it is the quick way
to see what a group still lacks after placing and routing it.
Args:
designators (list): Components whose nets to check. Their pads name
the ends of each connection (from_pad, to_pad), and unless area is
given, the area is their pads' extent grown by margin_mils.
nets (list): Nets to check (exact names, any case). With neither
designators nor nets, every net.
area (list): [x1, y1, x2, y2] in mils from the board origin; each
connection says whether both its ends lie in it (inside).
margin_mils (float): See designators (default 40).
max_connections (int): Most connections listed (default 200); the
counts cover them all.
board_path (str): Full path of the .PcbDoc; empty for the focused
board, or the one the PCB tools last used.
With designators, only connections that end at one of their pads or lie
wholly inside the area are listed: a group's own connections and the
ones leaving it, not the rest of a board-wide net such as GND.
Altium does not update its ratsnest after copper added by a script, so
the nets are analyzed first. Analyzing can join straight track segments
that continue each other into one (the copper stays the same), as
Altium does after interactive routing.
Returns:
JSON: connection_count, inside_count (both ends in the area),
by_net counts, area, and connections (net, from, to, from_pad,
to_pad, length in mils, inside), longest first.layout_duplicatortool First step of layout duplication. Selects source components and returns data to match with destination components.Filesoutside text
First step of layout duplication. Selects source components and returns data to match with destination components.
Returns:
str: JSON object with source and destination component data for matchinglayout_duplicator_applytool Second step of layout duplication. Applies the layout of source components to destination components.Filesoutside text
Second step of layout duplication. Applies the layout of source components to destination components.
Args:
source_designators (list): List of source component designators (e.g., ["R1", "C5", "U3"])
destination_designators (list): List of destination component designators (e.g., ["R10", "C15", "U7"])
Returns:
str: JSON object with the result of the layout duplicationlist_open_documentstool List the documents open in Altium.Filesoutside text
List the documents open in Altium.
Returns:
str: JSON with documents [{path, kind, modified, active}]: kind as
Altium names it (PCB, SCH, PCBLIB, ...), modified when it has
unsaved changes, active for the one in frontmodify_pcb_objectstool Change copper on a PCB: the width of tracks and arcs, the size of vias,Filesoutside text
Change copper on a PCB: the width of tracks and arcs, the size of vias,
the net, or the layer.
Objects are picked as for delete_pcb_objects, and at least one filter
must narrow the match. Each change applies where it makes sense:
width_mils to tracks and arcs, via_diameter_mils and via_hole_mils to
vias, new_layer to tracks, arcs, fills and regions, new_net to all ("" removes
the net). A via whose hole would not fit inside its diameter is left as
it is and counted. A polygon given another net pours again. Locked
objects are left alone unless include_locked. One undo step in Altium.
Changed copper inside a pour leaves the pour as it was: repour it, and
run DRC after changing widths or via sizes.
Args:
kinds, net, layer, area, designators, margin_mils, include_locked:
The filters, as for delete_pcb_objects.
width_mils (float): New width of tracks and arcs.
via_diameter_mils, via_hole_mils (float): New via size; either alone
is checked against each via's other size.
new_net (str): New net; "" removes the net; leave out to keep it.
new_layer (str): Copper layer to move tracks, arcs, fills and
regions to.
dry_run (bool): List what matches without changing it.
board_path (str): Full path of the .PcbDoc; empty for the focused
board, or the one the PCB tools last used.
Returns:
str: JSON with matched, changed, unchanged (matched objects none of
the changes applies to), vias_left_as_hole_would_not_fit,
locked_skipped, and the first 50 objects as they were.move_componentstool Move components by RELATIVE offset from their current position (not absolute positioning)Filesoutside text
Move components by RELATIVE offset from their current position (not absolute positioning)
IMPORTANT: This moves components BY the offset amount, not TO a position.
For absolute positioning, use set_component_position instead.
Args:
cmp_designators (list): List of designators of the components to move (e.g., ["R1", "C5", "U3"])
x_offset (float): X offset distance in mils (positive = right, negative = left)
y_offset (float): Y offset distance in mils (positive = up, negative = down)
rotation (float): New absolute rotation angle in degrees (0-360), if 0 the rotation is not changed
Returns:
str: JSON object with the result of the move operationobjects_in_areatool List the board objects in a box: tracks, arcs, vias, pads, fills,Filesoutside text
List the board objects in a box: tracks, arcs, vias, pads, fills,
regions, polygons, texts and components, with their layer, net, owner and
geometry.
Each object has a "ref" that clearance and drag_copper take to find it
again (opaque: pass it on as is). To read a group's copper in the form
place_copper takes, to edit and place it again, use get_layout instead.
Regions, tracks and polygons are matched by their real shape, so a
board-sized pour is listed only where its copper reaches the box: a
polygon when one of its poured regions does (or, with none, such as a
hatched or unpoured one, its outline). A pour's copper (a region with
in_polygon) carries its polygon's name, net and layer.
Args:
bbox (list): [x1, y1, x2, y2] relative to the board origin, in unit.
layers (list): Only these layers, by Altium's name ("Top Layer",
"Mid Layer 1", "Mechanical 1"); through vias and Multi Layer pads
are on every copper layer (not on overlay, mask or mechanical
layers), a blind via on the layers it spans. Default all.
kinds (list): Only these: track, arc, via, pad, fill, region, polygon,
text, component. Default all.
nets (list): Only objects on these nets.
unit (str): "mil" (default) or "mm", for bbox and the reply.
limit (int): At most this many objects (default 500), counted after
the filters; total says how many match (null when there are more
than Altium was asked for), and truncated whether the list was
cut.
include_hidden (bool): Also list component designators and comments
that are switched off (hidden: true). Default False.
board_path (str): Full path of the .PcbDoc; default the focused board.
Returns:
str: JSON with total, returned, truncated and objects [{kind, layer,
net, component, coordinates..., ref}]place_componentstool Place multiple components at absolute positions in a single Altium transaction.Filesoutside text
Place multiple components at absolute positions in a single Altium transaction.
This is the batch version of set_component_position - prefer it whenever
placing more than one component, since every tool call is a full round
trip into Altium. The whole batch is one undo step.
Coordinate conventions: x/y are in mils relative to the board origin;
rotation is in degrees counterclockwise.
Args:
placements (list): One dict per component:
- designator (str, required): e.g. "R1"
- x (float, required): absolute X position in mils
- y (float, required): absolute Y position in mils
- rotation (float, optional): absolute rotation in degrees (0-360).
Omit (or pass -1) to keep the current rotation.
- layer (str, optional): "top" or "bottom" to set the board side
(the footprint is mirrored when flipped). Omit to keep the
current side.
- locked (bool, optional): lock (true) or unlock (false) the
component; omit to leave it as it is.
- designator_text, comment_text (dict, optional): put the
designator or comment text at {x, y (its anchor, as get_layout
reports it), rotation, height, stroke_width, visible,
autoposition ("manual" by default, or top_left ... bottom_right
as get_layout reports it)} after the move. Omit to let it move
with the part. (set_designator_positions places by centre.)
board_path (str): Full path of the .PcbDoc; empty for the focused
board, or the one the PCB tools last used. Give it whenever more
than one board is open, so the parts move on the right one.
Example:
placements=[{"designator": "R1", "x": 1000, "y": 2000, "rotation": 90},
{"designator": "C5", "x": 1050, "y": 2000, "layer": "bottom"}]
Returns:
str: JSON object with placed_count, missing_designators, and the final
x/y/rotation/layer of each placed component as Altium reports themplace_coppertool Add copper to a PCB in one undo step: tracks and arcs at any angle, vias,Filesoutside text
Add copper to a PCB in one undo step: tracks and arcs at any angle, vias,
fills, copper regions and polygon pours (arc edges, island and neck
removal, pour order). Everything is checked first (each net must exist,
each layer must be a signal layer), so a bad entry adds nothing. Pours go
in last, in pour_index order, and are poured around the copper added
with them. The nets the copper is on are analyzed afterwards, so the
ratsnest is current (this can join straight track segments that continue
each other; the copper stays the same). Run run_drc or
get_unrouted_connections afterwards.
Each list takes entries in get_layout's form (mils, degrees):
tracks: {net, layer, width, start: [x, y], end: [x, y]}
arcs: {net, layer, width, center: [x, y], radius, start_angle,
end_angle} (counter-clockwise from start to end)
vias: {net, x, y, diameter, hole, start_layer, end_layer}
(layers default to Top Layer and Bottom Layer)
fills: {net, layer, corner1: [x, y], corner2: [x, y], rotation}
regions: {net, layer, outline: [[x, y], ...]}
cutouts: {layer, outline} a polygon pour cutout, on a signal layer
or "Multi Layer" (all of them); pours with obey_cutouts
leave it free
pours: {net, layer, outline, name, hatch ("solid", "hatched_45",
"hatched_90", "vertical", "horizontal", "none"), pour_over
("same_net", "same_net_polygons", "none"),
remove_dead_copper, remove_islands (below island_area_sq_mils,
default 2500), remove_necks (narrower than neck_width_mils,
default 5), grid, track_width, arc_approximation,
pour_index, locked, obey_cutouts (default true),
optimal_void_rotation (default false)}
outline vertices are [x, y] or {x, y, arc: {center, radius,
start_angle, end_angle}} for an arc edge to the next vertex.
net "" is no net. Coordinates are mils from the board origin.
Args:
tracks, arcs, vias, fills, regions, cutouts, pours (list): Copper
to add.
layout (dict): A whole get_layout result; its copper lists are added
too (its components are not moved: use place_components).
transform (dict): Move everything: {"dx", "dy", "rotation" (degrees,
about "about": [x, y], default the origin), "mirror" (mirror x
before rotating)}. Fills only shift.
rename_nets (dict): {old net: new net}, e.g. to repeat a channel.
board_path (str): Full path of the .PcbDoc; empty for the focused
board, or the one the PCB tools last used.
Returns:
JSON: counts added (tracks, arcs, vias, fills, regions, cutouts) and each pour
with the pieces of copper it poured (0 means it poured nothing), or
the problems that stopped it.place_cutouttool Add a cutout to a PCB: a hole in polygon pours, or in the board itself.Filesoutside text
Add a cutout to a PCB: a hole in polygon pours, or in the board itself.
kind "polygon" keeps polygon pours out of the area on one signal layer
(or on every signal layer with layer "all"), as Altium's Polygon Pour
Cutout does. kind "board" cuts the area out of the board (a slot or
opening). Either way the polygons the cutout overlaps are repoured.
Args:
outline (list): Corners [[x, y], ...] in mils relative to the board
origin, in order around the shape (at least three).
kind (str): "polygon" (default) or "board".
layer (str): For a polygon cutout, the signal layer ("Top Layer",
a stack name) or "all". Ignored for a board cutout.
board_path (str): Full path of the .PcbDoc; empty for the focused
board, or the one the PCB tools last used.
Returns:
str: JSON with how many cutout regions were added and how many
polygons were repoured.place_label_blocktool Apply a label block from get_label_block_options: move the parts'Filesoutside text
Apply a label block from get_label_block_options: move the parts'
designators into the block (shown, at the block's text size) and draw
its link on the silkscreen, then check both with Altium's rules. An
earlier block of any of these parts is replaced (its link removed).
Args:
designators (list): The same designators given to get_label_block_options.
option (int): Which option (default 1).
whole_row (bool): As given to get_label_block_options.
Returns:
JSON: the block's parts, link and marker, ok, and any Altium
violations of the labels or the link graphics.place_polygon_pourtool Add a polygon pour (copper area, e.g. a ground pour) to a PCB and pour it.Filesoutside text
Add a polygon pour (copper area, e.g. a ground pour) to a PCB and pour it.
The pour keeps the board's clearance rules from other nets and joins
same-net pads and tracks as the polygon connect rule says. Cut holes in
it with place_cutout.
Args:
outline (list): Corners [[x, y], ...] in mils relative to the board
origin, in order around the shape (at least three; it closes by
itself). Straight edges only.
layer (str): Signal layer, by its stack name or Altium's name, e.g.
"Top Layer".
net (str): Net to pour; it must exist on the board. Empty for an
unconnected pour.
name (str): Polygon name; empty lets Altium name it.
hatch (str): "solid" (default), "hatched_45", "hatched_90", or
"none" (outline only).
pour_over_same_net (bool): Pour over same-net tracks and pads.
remove_dead_copper (bool): Remove islands not connected to the net.
track_width_mils (float): Hatch track width; 0 for Altium's default.
grid_mils (float): Hatch grid; 0 for Altium's default.
board_path (str): Full path of the .PcbDoc; empty for the focused
board, or the one the PCB tools last used.
Returns:
str: JSON with the polygon's name, layer, net and what it poured:
poured_regions, one per separate piece of solid copper, and
hatch_tracks for a hatched pour. When nothing was poured it
says why it may be: no room, or every piece touched nothing on
its net and was removed as dead copper.place_viastool Add vias to a PCB: stitching, fan-out, or a via at the end of a track.Filesoutside text
Add vias to a PCB: stitching, fan-out, or a via at the end of a track.
Args:
vias (list): Via positions in mils relative to the board origin,
each [x, y] or an object {"x": .., "y": .., "net": ..,
"diameter_mils": .., "hole_mils": .., "start_layer": ..,
"end_layer": ..} whose keys override the defaults below for
that via.
diameter_mils (float): Via pad diameter.
hole_mils (float): Drill diameter, smaller than diameter_mils.
net (str): Net of the vias; it must exist on the board. Empty for
vias without a net.
start_layer (str): Layer the via starts on, e.g. "Top Layer".
end_layer (str): Layer it ends on, e.g. "Bottom Layer". Set both for
a blind or buried via.
board_path (str): Full path of the .PcbDoc; empty for the focused
board, or the one the PCB tools last used.
Every net and layer is checked before anything is added, so a bad entry
adds nothing. Run run_drc afterwards: a via is not checked against
clearance when it is placed.
Returns:
str: JSON with how many vias were added.preview_ecotool Show what Design > Update PCB would change, without running it: theFilesoutside text
Show what Design > Update PCB would change, without running it: the
differences between the compiled schematics and the board, as data.
Run it before an Update PCB, in particular to catch rooms and classes the
ECO would remove (a room drawn for a class the schematics no longer make
disappears with the update), footprint changes and net renames.
Compiles the project in memory (nothing is saved) and reads the board
without bringing it to the front. Components match by unique id, nets by
their pins (a net whose pins stay together under a new name is a
rename), rooms and classes by name. The project's options, as saved in
the .PrjPcb, are followed: kinds the comparator ignores (Project Options
> Comparator) or the ECO does not generate (ECO Generation), and classes
and rooms the project does not generate (Class Generation), are left
out and counted in skipped_by_project_options. Duplicate component
class names (Altium's "Class already exists" warning, usually from a
sheet symbol that lists several files) are explained in
duplicate_component_classes. As Altium's ECO does, with "Netlist single
pin nets" off a pin alone on an auto-named net (NetR1_1) counts as on no
net (it is not connected, and leaves a board net it is on), while a
named one-pin net is made with its pin (Altium lists that as Add Nets
only); board parts with no schematic link are left alone and listed in
board_only_components, outside the summary.
Not compared, so an empty summary means "no differences of the kinds
compared", not that an Update PCB would change nothing: net class
members (net classes match by name only), component parameters,
differential pairs, rules from parameter sets, and room scope and
members (rooms match by name only).
Args:
project_path (str): Full path of the .PrjPcb; default the focused project.
pcb_path (str): The board to compare; default the project's PCB.
max_per_kind (int): At most this many entries per kind (default 50);
"summary" always has the full counts.
Returns:
str: JSON with project_path, pcb_path, unsaved_in_altium (sheets
compiled from unsaved edits), summary {kind: count}, and per kind:
add_components, remove_components, change_designators,
change_footprints, change_comments, add_nets, remove_nets,
rename_nets, change_pin_nets, add/remove_component_classes,
change_component_class_members, add/remove_net_classes,
add_rooms, remove_rooms, duplicate_component_classes,
board_only_components, skipped_by_project_options ({kind,
count, reason}); project_options_note if the .PrjPcb could not
be read (then nothing is left out)query_objectstool Find PCB objects with Altium's own query language, as the PCB FilterFilesoutside text
Find PCB objects with Altium's own query language, as the PCB Filter
panel and rule scopes use it.
Examples: "IsVia And InNet('GND')", "IsTrack And OnTopLayer And
(Width < 6mil)", "InComponent('U1') And IsPad", "IsPolygon",
"InNetClass('Power')". A component is found by Name ("IsComponent And
(Name = 'U1')"; there is no Designator property) and a pad by its full
name ("IsPad And (Name = 'U1-3')"). Text is quoted with ' and compared
as text: Name = 1 fails where Name = '1' works. Put each comparison in
brackets: IsComponent And Footprint = 'X' is read as
(IsComponent And Footprint) = 'X' and fails.
An expression Altium cannot read or evaluate comes back as an error with
Altium's message; the dialog it raises is answered, so Altium is not
left waiting.
Layers are named as the board names them in its layer stack
(OnLayer('GND1')); Altium's generic names ('Mid Layer 1', 'Mechanical
17') given to OnLayer(), ExistsOnLayer() or Layer = are translated to
the board's, so both work. Each object gives both: layer (generic) and
layer_name (the board's, when it has its own).
The engine has no position properties (X, Y): give a box as area
instead (clamped to Altium's design space, +-100,000 mil). It keeps the
objects whose bounds touch the box, so a pour larger than the box is
kept wherever its copper is.
Give sizes with a unit (6mil, 0.15mm). The engine reads bare numbers in
its own unit, which is not always the board's display unit, and a unit
written inside the query is a syntax error; so each value with a unit is
converted to the unit the engine uses on this board before the query
runs. Decimals take a dot. Quoted text is sent as written, units and
commas included (InNet('D0,1'), Comment = '4.7uF 2.2mm').
The engine works through the selection, so the user's selection is
selected again afterwards, also after a query Altium could not
evaluate; objects of kinds the PCB Selection Filter (Properties panel)
leaves out cannot be selected by a script and stay unselected. A filter
applied in the PCB Filter panel is cleared: a script cannot read it back
to restore it.
Args:
expression (str): The query.
area (list): Only objects touching [x1, y1, x2, y2], from the board
origin in unit. Default the whole board.
unit (str): "mil" (default) or "mm", for area.
limit (int): How many objects to list in full, 0 to 1,000,000
(0 lists none); matched counts all.
board_path (str): Full path of the .PcbDoc; empty for the focused
board, or the one the PCB tools last used.
Returns:
str: JSON with matched, by_kind counts, and the objects: kind, name
(component designator, pad, polygon, rule, net), net, layer,
layer_name and bounds in mils from the board origin.
expression_run is what the engine ran.
copper_polygons_without_net counts matched pours with no net,
which InNet() cannot find.reload_documenttool Close an open document and open it again from disk, e.g. after the fileFilesoutside text
Close an open document and open it again from disk, e.g. after the file
was replaced or edited outside Altium. Altium saves its own copy over the
file otherwise, so never change a file on disk while it is open without
reloading it here.
Args:
path (str): Full path of the open document
discard_changes (bool): Reload even when the document has unsaved
changes, dropping them. Default false: such a document is refused.
Returns:
str: JSON with path, kind, and the file's size (file_size) and
modification time (file_mtime, ISO 8601) as it was loadedremove_label_blocktool Remove the label block of these parts: its link graphics (leader orFilesoutside text
Remove the label block of these parts: its link graphics (leader or
index markers) are deleted; the designators stay where they are, ready
to be placed again.
Args:
designators (list): Any of the block's parts.
Returns:
JSON with the removed block's parts and link.render_pcbtool Draw a board area as a picture: copper (tracks, arcs, pads, fills,Filesoutside text
Draw a board area as a picture: copper (tracks, arcs, pads, fills,
pours), vias, overlay and the board outline, in Altium's layer colours on
black.
Drawn here from the board's objects, not captured from Altium's window:
nothing in Altium moves, zooms or comes to the front.
Args:
bbox (list): [x1, y1, x2, y2] relative to the board origin, in unit.
Default the whole board outline.
layers (list): Layers to draw, by Altium's name (case, spaces and
hyphens do not matter). Default Top Layer, Bottom Layer, Multi
Layer and Top Overlay; e.g. ["Bottom Layer", "Bottom Overlay"] for
the bottom side or ["Mid Layer 1"]. Through-hole pads and through
vias show with any copper layer, a blind via only with a layer it
spans.
dpi (float): Pixels per inch of board (default 300); lowered so the
longer side stays within 4000 pixels.
unit (str): "mil" (default) or "mm", for bbox.
board_path (str): Full path of the .PcbDoc; default the focused board.
Returns:
JSON (bbox, dpi, size, what was drawn per layer) and the PNGrepour_polygonstool Repour polygon pours on a PCB: all of them, or the ones the filters pick.Filesoutside text
Repour polygon pours on a PCB: all of them, or the ones the filters pick.
Repour after moving parts, tracks or vias through a pour, or after
changing clearance or polygon connect rules; Altium does not repour by
itself. The whole repour is one undo step.
Filters combine; with none, every polygon on the board is repoured.
Args:
names (list): Polygon names, any case. Names need not be unique (a
"GND" pour on each layer is common), so add layer to pick one.
net (str): Only polygons on this net.
layer (str): Only polygons on this signal layer, by stack name or
Altium's name ("Top Layer").
area (list): [x1, y1, x2, y2] in mils from the board origin: only
polygons overlapping it, e.g. around an edit. Overlapping, so a
whole-board pour counts for any area on it.
include_shelved (bool): Also repour shelved polygons, which
unshelves them. By default they are left shelved and listed.
board_path (str): Full path of the .PcbDoc; empty for the focused
board, or the one the PCB tools last used.
Returns:
str: JSON with how many polygons were repoured and, for each, its
name, layer, net and poured_regions (separate pieces of
copper) and hatch_tracks. shelved_skipped lists the shelved
polygons that matched and were left alone.rollback_altium_scripttool Undo a run_altium_script run by restoring the documents it snapshotted.Filesoutside text
Undo a run_altium_script run by restoring the documents it snapshotted.
Each document is closed in Altium without saving (dropping whatever the
script changed there), its copy from before the run is put back on disk,
and the documents that were open are opened again.
Refused, so that no work is lost:
- a document changed on disk since the run ended (saved later by the
user or by another run): restoring would overwrite that work. The
snapshot copies are listed so they can be restored by hand.
- a document that had unsaved changes in Altium before the run: those
changes were never on disk, so closing it would lose them.
- a document with unsaved changes in Altium now, including one the
script itself left unsaved: the user may have kept editing it since,
and closing it would lose those edits with the script's.
- a project with other open documents that have unsaved changes: closing
the project would ask to save them. Save or close them first.
Pass discard_unsaved=True to restore the documents with unsaved changes
anyway; files changed on disk and projects are always refused.
When Altium is not running, nothing can be open or unsaved: the files are
restored straight after the on-disk check, without starting Altium.
Args:
run_id (str): The "snapshot" run_id from run_altium_script's result.
discard_unsaved (bool): Also restore documents with unsaved changes
in Altium, losing those changes.
Returns:
str: JSON with the restored documents and which were reopened.route_connectionstool Route unrouted connections automatically: a maze router finds a path forFilesoutside text
Route unrouted connections automatically: a maze router finds a path for
each connection, every segment 0, 45 or 90 degrees, keeping the clearance
from other nets' copper and changing layer through a via where a route
needs it. For a group's local routing after it is placed (and fanned out
with fanout_pads). Each net gets the preferred width of its width rule
(the minimum where the preferred width finds no path) and the gap of
its clearance rule, unless width_mils or clearance_mils is given. Wider
nets are routed first, then shortest first; each route becomes an
obstacle for the next. Polygon pours are not obstacles: they pour again
around new copper (repour_polygons). Everything is added in one undo
step; check with run_drc and get_unrouted_connections.
Args:
designators (list): Route the connections of these components that
lie wholly inside their area (their pads' extent, as
get_unrouted_connections gives it); include_leaving adds those
leaving the group.
nets (list): Route the connections of these nets (inside area when
given).
area (list): [x1, y1, x2, y2] in mils from the board origin.
layers (list): Layers routes may use, e.g. ["Top Layer"] (default)
or ["Top Layer", "Bottom Layer"]; with more than one, vias
(through, Top to Bottom) change layer.
width_mils (float): One width for every net, instead of the rules.
clearance_mils (float): Gap to other nets' copper, instead of the
largest clearance rule gap of the nets routed.
via_diameter_mils, via_hole_mils (float): Size of a layer-change via.
grid_mils (float): Routing grid (default 2.5); finer finds paths
between fine-pitch pads but is slower.
include_leaving (bool): See designators.
max_connections (int): Most connections routed in one call.
dry_run (bool): Find the routes and return them without adding them.
board_path (str): Full path of the .PcbDoc; empty for the focused
board, or the one the PCB tools last used.
Returns:
JSON: routed and failed connections (net, from, to, pads, width, and
why a route failed), tracks and vias added, the widths used per
net, and the connections still unrouted afterwards. With dry_run,
the tracks and vias themselves.route_pathtool Route a net through waypoints, changing layer with vias, and check theFilesoutside text
Route a net through waypoints, changing layer with vias, and check the
new copper against the board's rules.
Every segment is exactly 0, 45 or 90 degrees: between two waypoints not
in line the route takes a straight leg and a 45 degree diagonal (as
route_track). A waypoint with another layer than the current one puts
a via at that waypoint and the route goes on in that layer.
The new tracks and vias are then checked like check_objects_drc (own
width and hole rules; clearance, short circuit and hole to hole against
everything near), and the violations returned. Hits on pour copper are
listed apart (pour_violations): the pour has not been repoured around
the new copper yet. With undo_on_violation the route is taken off again
when there is a violation other than a pour hit, within the same undo
step, so nothing of it is left.
Refused before anything is added: a layer the board does not have, a
surface-mount pad reached on another layer than its own (that would put
a via in the pad), and a pad or via on another net, unless the
allow_ options say otherwise.
Args:
net (str): The net; it must exist on the board.
start: Where to begin: a pad as "U1-3", a pad, via or component ref
from objects_in_area, or [x, y] (then give layer).
waypoints (list): Each [x, y], [x, y, "layer"], {"x", "y", "layer"},
or a pad "J1-2" or pad/via/component ref (typically the last);
x, y from the board origin. Layer names are not case-sensitive.
layer (str): The starting layer; default the start pad's layer
(Top Layer for a through-hole pad or a point).
width (float): Track width in unit; 0 (default) takes the width
rule's preferred width for the net on each layer.
via_size, via_hole (float): Via diameter and hole; 0 takes the
routing via style rule's preferred values.
via_span (str): "through" (default: Top to Bottom) or "layers" (only
the two layers it joins).
diagonal_first (bool): Diagonals at the start of each stretch.
corner_chamfer (float): Cut right-angle corners with 45 degree
segments of this length (in unit).
unit (str): "mil" (default) or "mm".
check (bool): Check the new copper (default True).
undo_on_violation (bool): Remove the route again when the check
finds a violation (pour hits, also on a hatched pour, do not
count); success is then false. Needs check.
dry_run (bool): Only plan: the segments and vias, nothing added.
allow_via_in_pad (bool): Allow reaching a surface-mount pad on
another layer, with a via in the pad (also the last pad: the
route ends in that via).
allow_other_net (bool): Allow a pad or via of another net as start
or waypoint (listed under warnings).
board_path (str): Full path of the .PcbDoc; default the focused board.
Returns:
str: JSON with the tracks and vias added (with refs for
drag_copper and check_objects_drc), the violations, and whether
the route was removed again.route_tracktool Add a routed track through waypoints on the focused PCB, every segmentFilesoutside text
Add a routed track through waypoints on the focused PCB, every segment
exactly 0, 45 or 90 degrees.
Between two waypoints that are not in line, the track takes a straight
leg and a 45 degree diagonal. The diagonal is computed from its own
start point, so its x and y runs are equal: nothing is snapped on its
own, which is what leaves stubs a few degrees off 45. Use this instead
of placing track segments from run_altium_script, and run
check_routing afterwards. It adds tracks only: no vias, and no DRC.
Args:
net_name (str): Net of the track; it must exist on the board.
layer (str): Layer name as get_component_pins and check_routing
report it, e.g. "Top Layer" or "Bottom Layer".
width_mils (float): Track width in mils.
points (list): Waypoints [[x, y], ...] in mils relative to the
board origin, at least two: usually a pad centre, any bends,
and the far pad or via centre.
diagonal_first (bool): Put the diagonal at the start of each
stretch instead of its end (default: straight, then diagonal).
corner_chamfer_mils (float): Cut each right-angle corner between two
straight legs with a 45 degree segment, setting back this far on
each leg (at most half the shorter leg). 0 leaves them square.
dry_run (bool): Only compute and return the segments.
Returns:
str: JSON with the segments in mils ([x1, y1, x2, y2]) and, unless
dry_run, how many tracks were added.run_altium_scripttool Run a DelphiScript snippet inside an isolated Altium sandbox and reportProcessesFilesoutside text
Run a DelphiScript snippet inside an isolated Altium sandbox and report
what happened, step by step.
Use this to develop and verify Altium API code before relying on it.
Each call writes the script into a fresh copy of SandboxScript/Sandbox.pas
with a unique file name and runs it with ScriptingSystem:RunScriptFile, so
a script that failed earlier can never be re-run from Altium's editor.
When Altium reports a compile or run-time error, the tool returns Altium's
message with the line in YOUR script, answers the dialog, stops the
debugger and confirms with a probe run that the next call will work. No
manual Ctrl+F3 or -REditScript:Stop is needed. Only scripts the MCP
started are ever stopped: a script the user is running or debugging in
Altium is left alone, and the tool says Altium is busy instead.
Writing the script:
- Call SandboxLog('...') before each risky statement. The log is flushed
after every call, so the last logged line identifies what failed.
- Assign findings to the string variable ResultText - it is returned.
- Variables: either start the script with your own block, e.g.
var
Doc, Comp : IDispatch;
X, Y : Integer;
or reuse the scratch variables S1..S9 (String), I1..I9 and B1..B3
(Integer), F1..F4 (Double), Obj1..Obj9 (IDispatch), List1..List3
(TStringList, created empty by the sandbox - reuse with .Clear, never
Free them), IntMan, DbDoc. Assigning an undeclared plain name is
refused before Altium is called. Do not assign to a for-loop variable
inside its loop (compile error). The var block is global: do not
declare a sandbox name again (S1, MM, ...).
- Functions and procedures: put them after the var block, before the
statements. They can use the var block, the scratch variables,
ResultText and the helpers:
var
N : Integer;
function Twice(X : Integer) : Integer;
begin
Result := X * 2;
end;
N := Twice(21);
ResultText := IntToStr(N);
Exit in the statements ends the script; the result is still returned.
- Refused before Altium is called, because Altium's message does not say
what is wrong: a reserved word or directive as a name (Label, Object,
Unit, File, Type, Out, Property, Index, Read, Write, Default, ...), a
sandbox name declared again, and a comparison next to and/or without
parentheses: 'if A = 1 and B = 2' is 'A = (1 and B) = 2' ("Then
expected"); 'not A = B' is '(not A) = B' and silently gives the wrong
answer. Write '(A = 1) and (B = 2)' and 'not (A = B)'. skip_lint=True
skips the reserved-word and precedence checks; a sandbox name
declared again is always refused.
- Calls known to crash Altium (GetState_DescriptionString, reading
.Corner or .BoundingRectangle through an IDispatch variable, ...) and
a PreProcess without PostProcess are refused before Altium is called:
a script that dies between PreProcess and PostProcess leaves Altium's
undo history broken until Altium is restarted.
- Every dialog the tool answers is saved as a picture first, listed in
"dialog_snapshots": Altium's own message boxes cannot be read from
outside, so open the picture to see the message.
- Helpers: MM(mm) converts millimetres to internal units;
OpenSchDoc(path) returns the ISch_Document, opening the file if needed
(GetSchDocumentByPath alone returns nil for a closed file, and a call on
nil stops the script); SaveDoc(path) marks a document modified and saves it.
- Numbers: FloatToStr, FormatFloat and StrToFloat follow the Windows
decimal separator, which may be a comma ('1,5'). Use FmtNum(V [,
decimals]) and FmtMM(coord [, decimals]) for text with a dot, and
ParseNum(s) and ParseMM(s) to read '1.5' or '1,5' ('15mil' and '1.5mm'
too for ParseMM, which returns internal units).
- Snapshots: before the run, the Altium documents the script names in
its strings (full paths to .SchDoc, .PcbDoc, .SchLib, .PcbLib, .OutJob,
.PrjPcb) are copied aside; pass snapshot=[paths] to choose them, or []
for none. A script working on GetCurrentPCBBoard or the focused
document names no path, so nothing is copied unless snapshot is given;
the result's "snapshot" then says so. Otherwise it gives the run_id
for rollback_altium_script, which closes them in Altium without saving
and restores the copies.
- Errors inside the script (undeclared identifiers, calls on nil, bad
conversions) are caught by the sandbox and come back as "script error"
with Altium's message and the last step; no try/except is needed.
- Loops: a running script cannot be stopped from outside, so a loop that
never ends would freeze Altium until it is killed. Every while and
repeat loop is therefore guarded: about 10 s before timeout_seconds all
loops exit, the rest of the script still runs (so a PostProcess after
the loop is not skipped), SaveDoc no longer saves, and the tool returns
"loop guard" with the loop's line. Make loops that delete or retry
objects bounded anyway (a fixed count, never the same object twice).
for loops are not guarded.
- The sandbox is standalone: helpers and constants from the production
units (TrimJSON, AddJSONProperty, ...) are NOT available; REPLACEALL is.
- Undo: wrap each edit in SchServer.ProcessControl.PreProcess(Doc, '') /
PostProcess(Doc, '') (PCBServer.PreProcess / PostProcess on a PCB), and
report changes to the robot manager (SCHM_PrimitiveRegistration for a new
object, SCHM_BeginModify / SCHM_EndModify around a change). An undo group
left open makes the user's own later edits in that document impossible
to undo until Altium restarts, so the sandbox closes any group the script
leaves open, even after an error, and reports it as
"undo_groups_closed": fix the script when you see it.
- Never register objects into a library document and never write to shared
or network library paths. Verify the target document kind first
(ObjectID 32 = schematic, 33 = symbol library).
- Copper: add routed tracks with route_track instead of computing segment
ends here, and run check_routing after moving tracks, vias or parts.
For API guidance - interfaces, object models, worked examples - use the
"altium-script" skill. ensure_altium_script_skill reports whether that
skill is installed and can install it.
Args:
script (str): DelphiScript statements to execute (body only, optionally
preceded by a var block and functions or procedures).
timeout_seconds (int): How long to wait for completion (default 120).
skip_lint (bool): Run even though the known-crash, precedence or
reserved-word check refused the script. Only for a false positive.
snapshot (list): Documents to copy before the run, for
rollback_altium_script. Default: those named in the script's
strings. [] takes none.
Returns:
str: JSON with success, the step log and the script's ResultText; on
failure Altium's error message and its location in the script,
the last step reached, and whether the executor was recovered.run_drctool Run the design rule check (DRC) on a PCB and list the violations.ProcessesFilesoutside text
Run the design rule check (DRC) on a PCB and list the violations.
Runs Altium's own batch DRC with the board's rules and the options last
set in its Design Rule Checker dialog. The dialog is answered from
outside Altium: it may flash on screen. Altium writes its usual report
beside the board (or in the project's output folder) and may open it.
The violations stay on the board, marked as Altium marks them.
A cancelled check leaves no violations, exactly like a clean board, so
"ran" says whether the check really ran: the Run button was pressed and
the dialog closed. "report" (when Altium wrote one) gives the per-rule
counts and confirms it independently.
Args:
board_path (str): Full path of the .PcbDoc to check. It is opened if
needed and brought to the front. Empty: the focused board, or
the one the PCB tools last used.
rules (list): Only violations of these rules: each is a rule's own
name or a rule kind ("Clearance", "Width", "Short-Circuit",
"Un-Routed Net", "Hole To Hole Clearance", ...), whole, in any
case and with or without spaces. "Clearance" is the electrical
clearance rules only, not hole-to-hole or silk clearances. The
whole check still runs: Altium checks every enabled rule.
nets (list): Only violations with an object on one of these nets.
area (list): Only violations located in [x1, y1, x2, y2] (mils from
the board origin), by their own or an object's position.
With any filter, matching_count counts the matching violations;
listed_by_rule always counts the ones listed.
max_violations (int): How many violations to list in full.
violation_count counts every violation the check found, but
Altium stops the check at its own violation limit (500 unless
changed in its Design Rule Checker dialog); "complete": false
then says the board may have more.
Returns:
str: JSON with ran, violation_count, the violations (rule,
description, x_mils/y_mils relative to the board origin, and
the primitives involved with their net and layer), and the
report's per-rule counts.run_output_jobstool Run specified output job containersFilesoutside text
Run specified output job containers
The OutJob's project must be open in Altium. A PDF (Publish) container
reports output_file and output_verified: true once Altium has written
that file. output_verified is false for generated-file containers and
for PDFs that Altium names itself (after each output, or from an
expression). When a PDF already exists and the container prompts before
overwriting (the default), Altium asks in a dialog and the run waits for
the answer.
Args:
container_names (list): List of container names to run
outjob_path (str): Full path to the OutJob file (optional). When empty,
the first OutJob found in the open projects is used, in project
order, regardless of which document has focus.
Returns:
str: JSON object with outjob_path (the file actually used) and the
results of running the output jobssearch_library_symboltool Search for a symbol by name in a schematic library (.SchLib) and navigate to it.Filesoutside text
Search for a symbol by name in a schematic library (.SchLib) and navigate to it.
Supports partial name matching (case-insensitive). Returns all matches and navigates
to the best match (exact match preferred, otherwise first partial match).
This tool will automatically open the library file in Altium if a path is provided,
so no SchLib needs to be open beforehand.
Args:
symbol_name (str): Name or partial name of the symbol to search for
library_path (str): Full file path to the .SchLib file (e.g. "C:\\Libraries\\MyParts.SchLib").
The tool will open this file in Altium if it is not already open.
If empty, uses the currently open library.
If no library is open and no path is provided, ask the user for the file path.
Returns:
str: JSON object with search results including matches, navigated symbol, and full symbol listset_component_positiontool Set a component's absolute position in the PCB layoutFilesoutside text
Set a component's absolute position in the PCB layout
Args:
cmp_designator (str): Designator of the component to position (e.g., "R1", "C5", "U3")
x (float): Absolute X position in mils
y (float): Absolute Y position in mils
rotation (float): Rotation angle in degrees (0-360), use -1 to keep current rotation
Returns:
str: JSON object with the result of the position operationset_designator_positionstool Place designators - by coordinates or relative to their part - and get aFilesoutside text
Place designators - by coordinates or relative to their part - and get a
verdict for each.
Each placement is either
- absolute: x, y = centre of the text box in mils (board origin), as read
off view_silkscreen or taken from get_designator_options, or
- relative: side = "above" | "below" | "left" | "right" | "inside" of its
own part, with gap (mils from the part's pads/silk; default just clear
of them) and offset (slide along that side, +x or +y).
Optional on both: rotation (0/90 top, 0/270 bottom read correctly;
default keeps a readable current rotation), height and stroke_width
(mils), visible (show/hide - hide only mounting holes and fiducials;
designators with no room go in a label block, see
get_label_block_options). A placement with only visible (or only
rotation/height) keeps the current centre.
dry_run=True changes nothing: every placement is checked against silk,
mask openings, the board edge, other designators where they are now and
each other, plus placement quality. Use it to test a set of neighbours
together before applying.
Otherwise all moves are one undo step, and with verify (default) each
moved designator is then checked with Altium's own silk rules and for
quality. ok=true means clean. The moves only go to the board the
snapshot was read from: if another PCB has been focused since, nothing
moves and the error names both boards.
Args:
placements (list): Dicts with designator plus x/y or side (gap,
offset), and optional rotation, height, stroke_width, visible.
dry_run (bool): Only check the placements.
verify (bool): After moving, run Altium's silk DRC on the moved
designators (default True).
Returns:
str: JSON with one verdict per designator: final x, y, rotation,
ok and problems.set_pcb_layer_visibilitytool Set visibility for specified PCB layersFilesoutside text
Set visibility for specified PCB layers
Showing layers is exclusive by default: the listed layers are shown and
every other layer is hidden, which suits a screenshot of just those
layers. Pass exclusive=False to show the listed layers and leave the rest
as they are. Hiding only ever hides the listed layers.
Names are matched the way Altium shows them, in any case and with or
without spaces and hyphens: "Multi-Layer" (the layer tab), "Top Solder"
(the Layer Stack Manager) and "Top Solder Mask" are all found, "Mid
Layer 1" finds a copper layer renamed e.g. "Inner 1", and "Top Silk" or
"Top Silkscreen" finds "Top Overlay" (the silkscreen). With a name no
layer has, nothing is changed and the reply lists the board's layers.
Every reply has previous_state, the visibility before the call; pass it
back as restore_state to put the view back as it was.
Args:
layer_names (list): Layers to change (e.g. ["Top Layer", "Multi Layer", "Mechanical 1"]),
or ["*"] for every layer
visible (bool): Whether to show (True) or hide (False) the specified layers
exclusive (bool): With visible=True, hide every layer not listed (default True)
strict (bool): Change nothing when a name is unknown (default True).
False applies the known names and reports the others in
not_found_layers, as this tool used to.
restore_state (dict): previous_state of an earlier reply: show and hide
the layers it names as it says. layer_names, visible and exclusive
are then ignored.
Returns:
str: JSON with success, updated_count, previous_state, and
resolved_names / unresolved / valid_names when names needed itview_silkscreentool Look at the silkscreen around some designators or in a region.Filesoutside text
Look at the silkscreen around some designators or in a region.
Renders one board side cleanly - no Altium UI, no copper clutter - with a
grid labelled in mils (board-origin coordinates, the same ones
set_designator_positions takes), so a free spot can be read straight off
the image. Shows solder mask openings, silk, part names at their centres,
every designator box, and marks designators whose current spot has a
problem in red. The designators asked about are cyan with a line to
their part.
Uses the board snapshot (refreshed by check_silkscreen, updated by
set_designator_positions, at most 5 minutes old). Pass refresh=True after
editing the board by hand in Altium.
Args:
designators (list, optional): Zoom to these parts and highlight them.
region (list, optional): [x_min, y_min, x_max, y_max] in mils to show
instead. Omit both for the whole board.
side (str, optional): "top" or "bottom". Default: the side of the
first designator, else top.
grid_mils (float): Grid spacing; 0 picks one to suit the zoom.
refresh (bool): Re-export the board from Altium first.
Returns:
JSON (view bounds, grid, legend, problems of the designators in view)
plus the image.which_ruletool Which design rule applies to a PCB object, or between two, and whetherFilesoutside text
Which design rule applies to a PCB object, or between two, and whether
they pass it: the rule the DRC picks (FindDominantRuleForObject or
...ForObjectPair) and the DRC's own test of it (Rule.ActualCheck, on
a pair both ways round), so net scope and the clearance matrix count as
they do in a DRC.
Each object is a query expression (as for query_objects) that must match
exactly one object, e.g. "IsPad And (Name = 'U1-3')". The engine has no
X or Y, so narrow one down by position with area_a / area_b, e.g.
object_a="IsVia And InNet('GND')", area_a=[1245, 795, 1255, 805].
Args:
object_a (str): Query expression for the object.
object_b (str): Query expression for the other object of a pair
rule; leave empty for a one-object rule (width, hole_size,
routing_via, solder_mask_expansion, paste_mask_expansion,
plane_connect).
rule_kind (str): clearance (default), short_circuit, hole_to_hole,
silk_to_silk, silk_to_mask, component_clearance, polygon_connect
(pairs); or one of the one-object kinds above.
area_a, area_b (list): Only objects touching [x1, y1, x2, y2] from the
board origin, in unit, count for object_a / object_b.
unit (str): "mil" (default) or "mm", for the areas.
board_path (str): Full path of the .PcbDoc; empty for the focused
board, or the one the PCB tools last used.
Returns:
str: JSON with the object(s), distance_mils (edge to edge) for a
pair, and the rule: name, descriptor, priority, enabled,
scopes, gap_mils for clearance, and passes (Altium's own check)
for the kinds the DRC tests.Text the model reads (90)
Every tool, prompt and resource description as written in the code: the model sees all of it, the user usually does not.
get_pour_report tool
Check what polygon pours poured: islands, slivers, and pours with no net
or no copper. Read only; repour first (repour_polygons) to check the
copper as the rules now make it.
Each polygon is listed with its pieces of solid copper and their sizes,
and flags:
* islands - poured into more than one separate piece;
* slivers - a piece smaller than sliver_sq_mils;
* no_net - the polygon has no net (dead copper);
* no_copper - poured nothing (no room, or all removed as dead copper);
* shelved - shelved, so it has no copper now.
A piece's area is its outline, holes not subtracted: an upper bound.
Args:
names, net, layer, area: Filters, as for repour_polygons; with none,
every polygon on the board.
sliver_sq_mils (float): A piece below this area is a sliver
(default 100 sq mil).
board_path (str): Full path of the .PcbDoc; empty for the focused
board, or the one the PCB tools last used.
Returns:
str: JSON with each polygon (name, layer, net, pieces, smallest
piece, copper area, slivers, flags) and the flagged ones first.(name computed at run time) tool
get_all_component_property_names tool
Get all available component property names (JSON keys) from all components
Returns:
str: JSON array with all unique property namesget_component_property_values tool
Get values of a specific property for all components
Args:
property_name (str): The name of the property to get values for
Returns:
str: JSON array with objects containing designator and property valueget_symbol_placement_rules tool
Get schematic symbol placement rules from a local configuration file
Returns:
str: JSON object with rules for placing pins on schematic symbolsget_library_symbol_reference tool
Get the currently open symbol from a schematic library to use as reference for creating a new symbol.
This tool should be used before creating a new symbol to understand the structure of existing symbols.
Returns:
str: JSON object with the reference symbol data including pins, their types, positions, and orientationssearch_library_symbol tool
Search for a symbol by name in a schematic library (.SchLib) and navigate to it.
Supports partial name matching (case-insensitive). Returns all matches and navigates
to the best match (exact match preferred, otherwise first partial match).
This tool will automatically open the library file in Altium if a path is provided,
so no SchLib needs to be open beforehand.
Args:
symbol_name (str): Name or partial name of the symbol to search for
library_path (str): Full file path to the .SchLib file (e.g. "C:\\\\Libraries\\\\MyParts.SchLib").
The tool will open this file in Altium if it is not already open.
If empty, uses the currently open library.
If no library is open and no path is provided, ask the user for the file path.
Returns:
str: JSON object with search results including matches, navigated symbol, and full symbol listcreate_schematic_symbol tool
Before executing, run get_symbol_placement_rules first.
For Altium API guidance while scripting, use the "altium-script" skill
(ensure_altium_script_skill reports whether it is installed).
Also look for a similar existing symbol to use as a style reference
before drawing: search a company/library .SchLib for a comparable part
(same category - op-amp, comparator, MCU, regulator, diode...) with
search_library_symbol, then dump it with get_symbol_primitives and
mirror its conventions (body style, pin lengths, pin name visibility,
grid spacing, glyph shapes). This produces symbols consistent with the
user's library. If no symbol library is available to reference, that is
fine - skip this step and proceed with the defaults below; do not treat
a missing reference as an error.
Create a new schematic symbol in the current library with the specified pins
Instructions: follow the rules from get_symbol_placement_rules and the
reference symbol's conventions; keep pins on a 100 mil grid
Pin name inversion/overbar: To show an overbar on a pin name (for active-low signals),
place a backslash after EACH character that should be overbarred.
Examples: R\\E\\S\\E\\T\\ renders as RESET with overbar.
C\\S\\/A0 renders as CS with overbar followed by /A0 without overbar.
Do NOT use ~{...} or other notation — only the backslash-per-character format works in Altium.
Args:
symbol_name (str): Name of the symbol to create
description (str): Description of the schematic symbol
pins (list): List of pin data in format
"pin_number|pin_name|pin_type|pin_orientation|x|y[|owner_part_id[|length[|show_name[|show_designator]]]]"
Pin types: eElectricHiZ, eElectricInput, eElectricIO, eElectricOpenCollector,
eElectricOpenEmitter, eElectricOutput, eElectricPassive, eElectricPower
Pin orientations: eRotate0 (right), eRotate90 (up), eRotate180 (left), eRotate270 (down)
x, y is where the pin meets the body; the pin extends from there
in its orientation's direction (left-side pins eRotate180, top pins eRotate90)
X,Y coordinates in mils
owner_part_id (optional): Part number the pin belongs to (1-based).
Use 0 for pins shared across all parts (e.g. power/GND).
Defaults to 1 if omitted. Only needed for multi-part symbols.
length (optional): pin length in mils (default 300)
show_name / show_designator (optional): 1 or 0 to show/hide
the pin name / number (e.g. op-amp pins often hide names)
part_count (int): Number of parts in the symbol (default 1).
Use >1 for multi-part symbols like quad op-amps or hex buffers.
graphics (list, optional): Explicit body graphics. When given, the
default auto-sized body rectangle is NOT drawn - the
graphics fully define the symbol body (triangles for
op-amps, diode glyphs, etc.). Entry formats (coordinates
in mils; part = owner part id, 1-based; width 0-3 =
zero/small/medium/large; solid 1 or 0):
- "line|part|width|x1|y1|x2|y2"
- "polyline|part|width|x1|y1|x2|y2|..." (any number of vertices)
- "polygon|part|width|solid|x1|y1|x2|y2|..." (closed/filled shape)
- "rectangle|part|width|solid|x1|y1|x2|y2"
- "arc|part|width|cx|cy|radius|start_angle|end_angle" (degrees CCW from 3 o'clock)
- "elliptical_arc|part|width|cx|cy|radius|secondary_radius|start_angle|end_angle"
- "ellipse|part|width|solid|cx|cy|radius|secondary_radius"
- "label|part|x|y|text" (free text annotation)
Tip: to reproduce an existing symbol's style, dump it first
with get_symbol_primitives and mirror its primitives.
Returns:
str: JSON object with the result of the component creationget_schematic_data tool
Get schematic data for components in Altium
Args:
cmp_designators (list): List of designators of the components (e.g., ["R1", "C5", "U3"])
Returns:
str: JSON object with schematic component data for requested designatorsget_pcb_layers tool
Get detailed information about all layers in the current Altium PCB
Returns:
str: JSON object with detailed layer information including copper layers,
mechanical layers, and special layers with their propertiesset_pcb_layer_visibility tool
Set visibility for specified PCB layers
Showing layers is exclusive by default: the listed layers are shown and
every other layer is hidden, which suits a screenshot of just those
layers. Pass exclusive=False to show the listed layers and leave the rest
as they are. Hiding only ever hides the listed layers.
Names are matched the way Altium shows them, in any case and with or
without spaces and hyphens: "Multi-Layer" (the layer tab), "Top Solder"
(the Layer Stack Manager) and "Top Solder Mask" are all found, "Mid
Layer 1" finds a copper layer renamed e.g. "Inner 1", and "Top Silk" or
"Top Silkscreen" finds "Top Overlay" (the silkscreen). With a name no
layer has, nothing is changed and the reply lists the board's layers.
Every reply has previous_state, the visibility before the call; pass it
back as restore_state to put the view back as it was.
Args:
layer_names (list): Layers to change (e.g. ["Top Layer", "Multi Layer", "Mechanical 1"]),
or ["*"] for every layer
visible (bool): Whether to show (True) or hide (False) the specified layers
exclusive (bool): With visible=True, hide every layer not listed (default True)
strict (bool): Change nothing when a name is unknown (default True).
False applies the known names and reports the others in
not_found_layers, as this tool used to.
restore_state (dict): previous_state of an earlier reply: show and hide
the layers it names as it says. layer_names, visible and exclusive
are then ignored.
Returns:
str: JSON with success, updated_count, previous_state, and
resolved_names / unresolved / valid_names when names needed itget_component_data tool
Get all data for components in Altium
Args:
cmp_designators (list): List of designators of the components (e.g., ["R1", "C5", "U3"])
Returns:
str: JSON object with all component data for requested designatorsget_selected_components_coordinates tool
Get coordinates and positioning information for selected components in Altium layout
Returns:
str: JSON array with positioning data (designator, x, y, rotation, width, height)get_all_designators tool
Get all component designators from the current Altium board
Returns:
str: JSON array of all component designators on the current boardget_component_pins tool
Get pin data for components in Altium
Args:
cmp_designators (list): List of designators of the components (e.g., ["R1", "C5", "U3"])
Returns:
str: JSON array, one entry per component with its placement info
(x/y in mils relative to the board origin, rotation in degrees
counterclockwise, layer) and a "pins" list. Per pin:
- x/y: absolute pad position (mils, relative to board origin)
- dx/dy: pad offset from the component origin in the footprint's
rotation-0 frame. To predict a pad position for a planned
placement: mirror dx (dx = -dx) if placing on the bottom layer,
rotate (dx, dy) counterclockwise by the planned rotation, then
add the planned component x/y.
- rotation: the pad's own rotation (NOT the component rotation)
- net, layer, width, height, shaperun_altium_script tool
Run a DelphiScript snippet inside an isolated Altium sandbox and report
what happened, step by step.
Use this to develop and verify Altium API code before relying on it.
Each call writes the script into a fresh copy of SandboxScript/Sandbox.pas
with a unique file name and runs it with ScriptingSystem:RunScriptFile, so
a script that failed earlier can never be re-run from Altium's editor.
When Altium reports a compile or run-time error, the tool returns Altium's
message with the line in YOUR script, answers the dialog, stops the
debugger and confirms with a probe run that the next call will work. No
manual Ctrl+F3 or -REditScript:Stop is needed. Only scripts the MCP
started are ever stopped: a script the user is running or debugging in
Altium is left alone, and the tool says Altium is busy instead.
Writing the script:
- Call SandboxLog('...') before each risky statement. The log is flushed
after every call, so the last logged line identifies what failed.
- Assign findings to the string variable ResultText - it is returned.
- Variables: either start the script with your own block, e.g.
var
Doc, Comp : IDispatch;
X, Y : Integer;
or reuse the scratch variables S1..S9 (String), I1..I9 and B1..B3
(Integer), F1..F4 (Double), Obj1..Obj9 (IDispatch), List1..List3
(TStringList, created empty by the sandbox - reuse with .Clear, never
Free them), IntMan, DbDoc. Assigning an undeclared plain name is
refused before Altium is called. Do not assign to a for-loop variable
inside its loop (compile error). The var block is global: do not
declare a sandbox name again (S1, MM, ...).
- Functions and procedures: put them after the var block, before the
statements. They can use the var block, the scratch variables,
ResultText and the helpers:
var
N : Integer;
function Twice(X : Integer) : Integer;
begin
Result := X * 2;
end;
N := Twice(21);
ResultText := IntToStr(N);
Exit in the statements ends the script; the result is still returned.
- Refused before Altium is called, because Altium's message does not say
what is wrong: a reserved word or directive as a name (Label, Object,
Unit, File, Type, Out, Property, Index, Read, Write, Default, ...), a
sandbox name declared again, and a comparison next to and/or without
parentheses: 'if A = 1 and B = 2' is 'A = (1 and B) = 2' ("Then
expected"); 'not A = B' is '(not A) = B' and silently gives the wrong
answer. Write '(A = 1) and (B = 2)' and 'not (A = B)'. skip_lint=True
skips the reserved-word and precedence checks; a sandbox name
declared again is always refused.
- Calls known to crash Altium (GetState_DescriptionString, reading
.Corner or .BoundingRectangle through an IDispatch variable, ...) and
a PreProcess without PostProcess are refused before Altium is called:
a script that dies between PreProcess and PostProcess leaves Altium's
undo history broken until Altium is restarted.
- Every dialog the tool answers is saved as a picture first, listed in
"dialog_snapshots": Altium's own message boxes cannot be read from
outside, so open the picture to see the message.
- Helpers: MM(mm) converts millimetres to internal units;
OpenSchDoc(path) returns the ISch_Document, opening the file if needed
(GetSchDocumentByPath alone returns nil for a closed file, and a call on
nil stops the script); SaveDoc(path) marks a document modified and saves it.
- Numbers: FloatToStr, FormatFloat and StrToFloat follow the Windows
decimal separator, which may be a comma ('1,5'). Use FmtNum(V [,
decimals]) and FmtMM(coord [, decimals]) for text with a dot, and
ParseNum(s) and ParseMM(s) to read '1.5' or '1,5' ('15mil' and '1.5mm'
too for ParseMM, which returns internal units).
- Snapshots: before the run, the Altium documents the script names in
its strings (full paths to .SchDoc, .PcbDoc, .SchLib, .PcbLib, .OutJob,
.PrjPcb) are copied aside; pass snapshot=[paths] to choose them, or []
for none. A script working on GetCurrentPCBBoard or the focused
document names no path, so nothing is copied unless snapshot is given;
the result's "snapshot" then says so. Otherwise it gives the run_id
for rollback_altium_script, which closes them in Altium without saving
and restores the copies.
- Errors inside the script (undeclared identifiers, calls on nil, bad
conversions) are caught by the sandbox and come back as "script error"
with Altium's message and the last step; no try/except is needed.
- Loops: a running script cannot be stopped from outside, so a loop that
never ends would freeze Altium until it is killed. Every while and
repeat loop is therefore guarded: about 10 s before timeout_seconds all
loops exit, the rest of the script still runs (so a PostProcess after
the loop is not skipped), SaveDoc no longer saves, and the tool returns
"loop guard" with the loop's line. Make loops that delete or retry
objects bounded anyway (a fixed count, never the same object twice).
for loops are not guarded.
- The sandbox is standalone: helpers and constants from the production
units (TrimJSON, AddJSONProperty, ...) are NOT available; REPLACEALL is.
- Undo: wrap each edit in SchServer.ProcessControl.PreProcess(Doc, '') /
PostProcess(Doc, '') (PCBServer.PreProcess / PostProcess on a PCB), and
report changes to the robot manager (SCHM_PrimitiveRegistration for a new
object, SCHM_BeginModify / SCHM_EndModify around a change). An undo group
left open makes the user's own later edits in that document impossible
to undo until Altium restarts, so the sandbox closes any group the script
leaves open, even after an error, and reports it as
"undo_groups_closed": fix the script when you see it.
- Never register objects into a library document and never write to shared
or network library paths. Verify the target document kind first
(ObjectID 32 = schematic, 33 = symbol library).
- Copper: add routed tracks with route_track instead of computing segment
ends here, and run check_routing after moving tracks, vias or parts.
For API guidance - interfaces, object models, worked examples - use the
"altium-script" skill. ensure_altium_script_skill reports whether that
skill is installed and can install it.
Args:
script (str): DelphiScript statements to execute (body only, optionally
preceded by a var block and functions or procedures).
timeout_seconds (int): How long to wait for completion (default 120).
skip_lint (bool): Run even though the known-crash, precedence or
reserved-word check refused the script. Only for a false positive.
snapshot (list): Documents to copy before the run, for
rollback_altium_script. Default: those named in the script's
strings. [] takes none.
Returns:
str: JSON with success, the step log and the script's ResultText; on
failure Altium's error message and its location in the script,
the last step reached, and whether the executor was recovered.rollback_altium_script tool
Undo a run_altium_script run by restoring the documents it snapshotted.
Each document is closed in Altium without saving (dropping whatever the
script changed there), its copy from before the run is put back on disk,
and the documents that were open are opened again.
Refused, so that no work is lost:
- a document changed on disk since the run ended (saved later by the
user or by another run): restoring would overwrite that work. The
snapshot copies are listed so they can be restored by hand.
- a document that had unsaved changes in Altium before the run: those
changes were never on disk, so closing it would lose them.
- a document with unsaved changes in Altium now, including one the
script itself left unsaved: the user may have kept editing it since,
and closing it would lose those edits with the script's.
- a project with other open documents that have unsaved changes: closing
the project would ask to save them. Save or close them first.
Pass discard_unsaved=True to restore the documents with unsaved changes
anyway; files changed on disk and projects are always refused.
When Altium is not running, nothing can be open or unsaved: the files are
restored straight after the on-disk check, without starting Altium.
Args:
run_id (str): The "snapshot" run_id from run_altium_script's result.
discard_unsaved (bool): Also restore documents with unsaved changes
in Altium, losing those changes.
Returns:
str: JSON with the restored documents and which were reopened.ensure_altium_script_skill tool
Check whether the "altium-script" skill is installed, and optionally
install it.
That skill documents the Altium DelphiScript API - interfaces, object
models, worked examples, conventions, and how to discover undocumented
processes - and is the reference to consult before writing scripts for
run_altium_script or debugging Altium API calls.
Source: https://github.com/coffeenmusic/altium-scripts-skill
Installing writes into the user's skills directory, so it only happens when
install=True is passed explicitly. Skills load at client startup, so a
newly installed skill becomes available after restarting the client.
Args:
install (bool): Install the skill if missing (requires git on PATH).
Returns:
str: JSON with installed (bool), the path checked, and the next step.get_footprint_primitives tool
Read the primitives of footprints in a PCB library (.PcbLib).
Modes:
- footprint_name omitted: inventory of every footprint with per-type
primitive counts (pads, tracks, arcs, fills, texts, regions, vias,
component_bodies)
- footprint_name given (exact, case-insensitive): full geometry dump -
pads (position, rotation, layer, sizes/shape per stack, hole size/
type/width/rotation, plating, paste_mode/paste_expansion,
mask_mode/mask_expansion, locked), tracks, arcs, fills, texts,
regions (outline vertices). Coordinates in mils relative to the
footprint origin (also for the footprint shown in the editor, which
Altium holds offset by the library origin); shapes and hole types as
raw Altium enum ints; layers as names. 3D component bodies are listed
apart in bodies_3d, not among the primitives, so the
create_footprints_batch round-trip is unchanged: model_file,
model_embedded, model_x/model_y (offset from the footprint origin),
standoff_height and overall_height (mils), layer, and
rotation_x/y/z (degrees) and model_z_offset (mils). The rotations and
offset come from the saved library file (Altium's script API cannot
return them); "placement" says so, and they are null for a body that
is not saved yet.
- footprint_name "*": full dump of every footprint
Use as the reference when recreating or validating footprints, and to
survey what a library requires.
Args:
library_path (str, optional): Full path to the .PcbLib. Omit to use
the currently focused PCB library (an already-open library is
only focused, never reloaded).
footprint_name (str, optional): Exact footprint name, or "*".
Returns:
str: JSON - inventory: {library_name, footprint_count, footprints:
[{name, description, <type counts>}]}; dump: primitives and
bodies_3d per footprintcreate_footprints_batch tool
Create many PCB footprints in a single Altium script run.
The batch equivalent of create_pcb_footprint with far broader coverage:
through-hole and SMD pads (full pad stack, holes, slots, plating,
rotation), tracks, arcs, fills, texts, and regions on any layer.
Verified by exact round-trips of complete production footprint
libraries. Prefer this for bulk imports/migrations; use
get_footprint_primitives on an existing footprint to learn the exact
field conventions.
Args:
spec_file (str): Path to a plain-text spec file, one record per line
(coords in mils, layers as names, shapes/hole types as raw
Altium enum ints, booleans as 1/0):
FPLIB|<path to .PcbLib> (optional first line: opens/focuses)
FOOTPRINT|<name>|<description>
EDITFOOTPRINT|<name> add MODEL3D records to an existing
footprint (never creates one; other
records under it are reported and
ignored)
PAD|name|x|y|rot|layer|plated|hole_size|hole_type|hole_width|hole_rot|top_x|top_y|top_shape[|corner_pct[|mode|mid_x|mid_y|mid_shape|bot_x|bot_y|bot_shape[|paste_mode|paste_expansion|mask_mode|mask_expansion]]]
Leave a field empty to skip it and still give a later one.
paste_mode/mask_mode are TMaskExpansionMode ints: 1 rule,
2 manual (with the expansion in mils). 0 (no mask) cannot
be set on a pad by script and is reported as a problem.
Omitted: rule. Every pad the tool creates is locked.
TRACK|x1|y1|x2|y2|width|layer
ARC|cx|cy|radius|start_angle|end_angle|width|layer
FILL|x1|y1|x2|y2|rotation|layer
TEXT|x|y|size|width|rotation|layer|mirror|ttf|text
REGION|layer|kind|x1|y1|x2|y2|...
MODEL3D|<STEP file>|<layer>|<rot_x>|<rot_y>|<rot_z>|<z_offset>[|<x>|<y>[|<embed 1/0>]]
add a 3D body from a STEP file: rotations in degrees,
z_offset (model height above the board) and x|y (offset
from the footprint origin) in mils, embedded in the
library unless embed is 0. Read the result back with
get_footprint_primitives (bodies_3d); its rotations and
z offset appear only once the library is saved.
The library is left modified and unsaved; the user saves it.
Returns:
str: JSON with created and edited counts, models_added,
primitive_errors, failed names and problems (e.g. a missing
model file, mask mode 0, a record EDITFOOTPRINT ignores)build_schematic tool
Build a wired schematic on a NEW sheet from a circuit description.
READ dev/SCHEMATIC_CONVENTIONS.md BEFORE CALLING. This tool places exactly
what it is given; it does not lay out or correct spacing. The conventions
file records the drafting rules that make the result readable, each one
learned by getting it wrong. The ones that most often produce a plausible
but wrong sheet:
* A pin's connection point is NOT Pin.Location - it is PinLength further
along the pin. Do not guess coordinates. Call with parts only first,
read the returned pin_map, then call again with wires routed from those
measured coordinates.
* Never run a riser in a pin's connection column; it drives through every
pin sharing that column.
* Give a shunt part one grid of wire between its pin and the node it taps,
rather than putting the junction on the pin.
* A net label that does not TOUCH its wire names nothing.
* A shunt part occupies the band below its rail. Do not route another net
through that band - the wire will pass through the symbol body.
* A ground port's "GND" label is always drawn (ShowNetName cannot hide it)
and occupies ~300 mil below the port. Keep wires out of that band.
Once the sheet is saved, run check_schematic on it and fix what it finds.
Args:
parts: component dicts. Required keys: designator, symbol_library
(full path of a .SchLib file; .IntLib is not supported),
symbol, x, y (mils). Optional: design_item_id, orientation (0-3),
mirror (0/1), comment, description, footprint,
parameters ({name: value}).
wires: each a flat list of alternating x,y in mils, e.g.
[3900, 3000, 5300, 3000, 5300, 4900] - two segments, three points.
junctions: [{"x":..,"y":..}] - only where 3+ branches actually meet.
net_labels: [{"x":..,"y":..,"orientation":0,"text":"LED+"}] - the
coordinate must lie on a wire.
power_ports: [{"x":..,"y":..,"orientation":3,"style":5,"text":"GND",
"show_net_name":false}]. Harvest style/orientation from an existing
sheet rather than guessing: 5 = digital ground, 2 = supply bar.
notes: [{"x":..,"y":..,"text":".."}] free text.
All coordinates are mils and keep their fractions, so a metric sheet
can be drawn exactly (1 mm = 39.3700787 mil). The pin_map has the
same precision: route from its values unrounded, or a wire ends up
a few microns out of level and turns diagonal when its part moves.
Returns:
JSON with the created sheet name, counts, and the pin map - every
placed pin's true connection point, for routing a follow-up call.get_schematic_pins tool
The pins of a schematic sheet's parts, live from Altium: each pin's
connection point (the outer end, where a wire must end), number, name,
electrical type and whether it is hidden. Only the part and display mode
each component shows are listed. Unsaved changes in Altium are seen.
Args:
sheet_path (str): Full path of the .SchDoc; opened if not open.
designators (list): Only these components; empty for all.
unit (str): "mil" (default) or "mm" for the coordinates.
Returns:
str: JSON with the pins: designator, part, pin, name, x, y,
electrical, hidden.edit_schematic tool
Change an existing schematic sheet: move, rotate, delete or place parts,
set parameters, move designators and parameter text, add wires, net
labels, power ports, junctions and no-ERC markers, and delete objects.
The whole edit is one undo step in Altium (Ctrl+Z takes it all back),
and the user's own edits stay undoable. Operations run in order; one
that fails is reported in "errors" and the rest still run.
Coordinates are absolute sheet coordinates, Altium's origin at the
bottom left, in `unit` ("mil" or "mm"). check_schematic reports
positions and suggestions in the sheet's own unit (mm for a metric
grid), so pass the same unit to apply its suggestions directly.
Operations, each a dict with "op":
move_component designator, [part], [x, y], [rotation 0/90/180/270],
[mirror true/false]. x, y is the part's origin.
delete_component designator, [part]
place_component library (.SchLib path), symbol, designator, x, y,
[rotation], [mirror], [comment]. For a part from a
database library, dblib (.DbLib path) and
part_number (its key), [table], in place of library
and symbol: the row gives the symbol, footprints,
description and parameters, and the part is linked
to the DbLib as when Altium places it (Excel tables)
set_parameter designator, name, value, [part], [visible]
(creates the parameter when missing)
move_text designator, name ("Designator", "Comment" or a
parameter), [part], [x, y], [justification 0-8:
bottom-left, bottom-centre, bottom-right, middle-left,
..., top-right], [orientation 0-3], [visible]
add_wire points [[x, y] or "U20.VCC", ...]: a point may name
a pin, by number ("U20.3") or name ("U20.VCC")
add_net_label x, y (on a wire), text, [orientation], [justification]
add_power_port x, y, text, [style: bar, arrow, circle, wave,
power_ground, signal_ground, earth], [orientation
0-3, default 1 = up], [show_net_name]
add_junction x, y
add_no_erc x, y
add_port x, y (its left end, or bottom end when vertical),
name, [io_type: unspecified, output, input,
bidirectional], [style: right (default), left,
left_right, none, and vertical: top, bottom,
top_bottom, none_vertical], [width]:
a width turns auto size off, so the port keeps its
length and stays on its wire when renamed
edit_sheet_symbol sheet (its sheet name, or file name if unique),
[x, y] (top left; entries and texts move along),
[width, height], [fill_color, border_color]
("#RRGGBB"), [line_width smallest/small/medium/
large], [name_x, name_y], [file_x, file_y] (where
the sheet name and file name texts sit). A size
that would leave an entry outside is refused; on a
resize the right and bottom entries move with their
edge (wires to them are not dragged)
edit_sheet_entry sheet, name, [side left/right/top/bottom],
[distance] (from the symbol's top edge on the left
and right sides, from its left edge on the top and
bottom), [io_type], [style, as add_port], [new_name]
move_wire_vertex x, y, to_x, to_y: moves the vertex at x, y of every
wire with one there (an end or a corner), so wires
that meet there stay joined; junctions, net labels
and power ports at x, y, and ports with an end
there, move with it; also to trim a wire. Refused
when a wire passes through x, y mid-segment (a T
connection)
move_net_label x, y (the label's location), [text], [to_x, to_y],
[orientation], [justification],
[snap_to_wire_end] (true, or a search radius in
unit: puts the label on the nearest wire end to its
target, 100 mil by default)
delete_at kind (wire, net_label, power_port, junction, no_erc,
port, note), x, y, [text]: removes a wire passing
through the point, or the object located there
"part" picks one part of a multi-part component (1 = A, ...).
The add_* operations with x, y also take "at": "U20.VCC" instead, to
place a label, port, power port, junction or no-ERC on a pin. Pins are
read live from the sheet (see get_schematic_pins) before anything is
changed; an unknown pin or a name several pins share is an error. So a
reference to a part that an earlier operation in the same call moves,
places or deletes is refused: refer to it in a second call. On a
multi-part part, "U1A.3" names pin 3 of part A; a pin common to every
part (often the power pins) needs the part letter.
Args:
sheet_path (str): Full path of the .SchDoc; opened if not open.
operations (list): The operations above, applied in order.
unit (str): "mil" (default) or "mm".
save (bool): Save the sheet afterwards (needed before
check_schematic, which reads the saved file). Otherwise it is
left modified for the user to review and save.
Returns:
str: JSON with how many operations were applied and the errors.check_schematic tool
Check a schematic sheet for drafting problems that make it hard to read.
Run it after drawing or editing a sheet (build_schematic, run_altium_script
or by hand), fix what it reports, and run it again. It reads the SAVED
file and does not need Altium, so save the sheet first; unsaved edits are
not seen.
Issue types, most important first:
* pin_tap - a two-pin part (decoupling cap, pull-up) joins its net AT its
own pin. Move the part so a short wire (a couple of grids) runs from
the pin to a junction on the net; suggest.junction_at shows where.
* label_not_at_end - a net label sits along a wire, away from the wire's
free end. Put it at the end (suggest gives the point).
* label_justification - a label at the free end whose text hangs off
the end of the wire. Justify it so the text runs back along the wire:
bottom-right (2) when the wire ends to the right, bottom-left (0)
when it ends to the left. A middle-justified (3/5) label anchored on
the end, reading outward like a port, is also accepted.
* sheet_entry_margin - a sheet symbol's first entry sits well below its
top edge. Altium's default is one grid (100 mil; 3 mm on a 1 mm grid);
extra room at the bottom is fine.
* sheet_symbol_text - a sheet symbol's designator or file name is not
above it. Both go above: file name on the top edge, designator a line
(100 mil) above it, both bottom-left justified at the left edge.
* label_orientation, label_off_wire, dangling_wire, wire_through_body.
* pin_off_grid - a part whose pins sit a few microns (up to 1 mil) off
the grid. Every wire drawn to them comes out slanted. When the part
itself is on the grid its drawing was shifted from its origin. When
every pin is off by the same amount, suggest gives the fix:
move_component_to (an on-grid position for edit_schematic's
move_component) when the whole part is that far off the grid, else
shift_contents_by. Pins off by different amounts get no suggestion:
the symbol needs fixing in its library.
* slanted_wire - a wire segment a little (1 um to half a grid) out of
level or plumb. It looks straight, but dragging a part on it turns it
diagonal. Usually a symbol whose pins are off the grid (then the
issue names the pin) or coordinates rounded to whole mils.
suggest.move_end/to give the end to move, at full precision:
delete_at the wire and add_wire it again with the new end.
* text_overlap - a designator, parameter, net label or port text
overlapping a wire, a pin, a part or other text. For part text the
issue carries suggest.texts: positions (x, y, justification) for the
designator and each visible parameter that collide with nothing, e.g.
designator left and value right of a vertical cap.
Coordinates are in the sheet's units ("unit": mm for a metric grid,
otherwise mil) with Altium's origin at the bottom left.
Args:
path: a .SchDoc, a .PrjPcb (every sheet it lists), or a folder (every
.SchDoc in it, not recursive).
max_issues_per_sheet: cap on issues listed per sheet; counts are
always complete.
Returns:
JSON: per sheet, the issue counts and the issues.check_hierarchy tool
Check that a project's sheets are connected: every sheet entry against the
ports of its child sheet, harness types, and harness definitions.
Design >> Synchronize Sheet Entries and Ports does this for one sheet
symbol, by exact name. This covers the whole project at once, pairs that
probably belong together under different names, and the harness errors
the ERC reports without a location. It reads the SAVED files and does not
need Altium, so save first.
Issue types, by severity:
error
* probable_pair - an entry and a port that do not connect but belong
together (same harness type, same name apart from case/separators, or
a similar name). suggest renames the port to the entry's name, or the
entry when the child sheet is used by several sheet symbols;
alternative gives the other way round.
* harness_type_mismatch - entry and port of the same name with
different harness types.
* harness_conflict - one harness type defined with different entries on
two sheets (the ERC's fatal "Conflicting harness definition");
variants lists which entries only one side has.
* harness_type_undefined - an entry or port uses a harness type no
harness connector defines.
* signal_harness_untyped - a signal harness that reaches no harness
connector and no typed port or entry, with its location (the ERC's
fatal "Missing harness type on harness", which gives none).
* signal_harness_type_conflict - a signal harness joining two types.
* child_sheet_missing, sheet_symbol_without_file.
warning
* entry_without_port, port_without_entry - unmatched on one side.
linked_on_other_instance marks a port another sheet symbol using the
same child does link (the ERC is silent about this instance).
* io_mismatch, io_unspecified - I/O types of entry and port differ
(not for harness entries and ports, which have none in Altium).
* name_case, duplicate_entry, child_not_in_project.
* entry_unwired - nothing attached to the entry on the parent sheet.
* harness_file_stale, harness_file_missing - a <sheet>.Harness file
that disagrees with the sheet's harness connectors.
info
* entry_matches_power_port - no port for the entry, but a power port
of that name on the child sheet (power ports connect globally).
* harness_order, top_sheet_ports, sheet_not_in_hierarchy,
harness_file_not_in_project.
Locations are in mils, Altium's origin at the bottom left. Sheet symbols
are given by designator and location (symbol_at), since several symbols
may share a designator.
Args:
project: the .PrjPcb.
min_severity: "error", "warning" (default) or "info": the least severe
issues listed. Counts always cover every severity.
max_issues: cap on issues listed.
Returns:
JSON: settings, top sheets, issue counts by severity, and the issues.create_symbols_batch tool
Create many schematic symbols, or edit existing ones, in a single
Altium script run.
Use instead of repeated create_schematic_symbol calls when creating
more than a handful of symbols (bulk library imports/migrations): one
script launch instead of one per symbol, and pipe-delimited plain text
instead of JSON so field text (commas, brackets, spaces) is preserved
exactly. Verified by exact round-trips of a complete 284-symbol
production library.
Args:
spec_file (str): Path to a plain-text spec file, one record per line:
LIBRARY|<path to .SchLib> (optional first line: opens/focuses;
an already-open library is only
focused, never reloaded)
SYMBOL|<name>|<description>|<part_count>
PIN|<same pipe fields as create_schematic_symbol pins>
GRAPHIC|<same entry format as create_schematic_symbol graphics>
EDITSYMBOL|<name> edit an existing symbol instead (its pins
and graphics are left alone; a missing
symbol is reported as failed, never created)
COMMENT|<text>[|<visible 1/0>] set the Comment (empty text
is allowed); hidden unless visible is 1
DESCRIPTION|<text> set the Description
SYMPARAM|<name>|<value>|<visible 1/0>[|x|y[|justification[|font]]]
add a symbol parameter, or replace one with
that name. By default, visible ones without
x|y go below the body's bottom-left corner,
left-aligned, 100 mil apart in record order
(leave a field empty to skip it and still
give a later one). justification:
bottom_left, bottom_center, bottom_right,
center_left, center, center_right, top_left,
top_center or top_right. font: <font
name>:<size>, e.g. "Arial:10" (resolved by
name, so it works in any document). Omitted
fields keep the parameter's own. A parameter
the tool positions gets Autoposition off, so
Altium does not move it later.
PINPARAM|<pin number>|<name>|<value> add (or replace) a hidden
parameter on every pin with that number
PINDESC|<pin number>|<text> set the Description of every pin
with that number
PINSYMBOL|<pin number>|<edge>|<symbol> set an IEEE symbol of
every pin with that number. edge: inside,
inside_edge, outside_edge or outside.
symbol: a TIeeeSymbol name without the
leading "e", any case - none, dot, clock,
activelowinput, activelowoutput, schmitt,
analogsignalin, digitalsignalin, opencollector,
hiz, ... (the full list is in the
altium-script skill, SCH_API_Reference.md,
TIeeeSymbol). An unknown edge or symbol is
reported under problems.
PINFUNC|<pin number>|<F1>/<F2>/... optional: replace the
Functions list (Properties panel > Pin >
Functions) of every pin with that number,
in the order given, e.g.
PINFUNC|23|ETH1_MDIO/USART2_TX/TIM2_CH3.
Use it only when the user asks for pin
functions; nothing sets them otherwise, not
even from a pin name with '/' in it. Names
cannot contain '/' or '|'. A script cannot
clear the list, so an empty one is reported
under problems; Altium merges repeated names,
and a stored list that differs is reported.
These records work after SYMBOL and EDITSYMBOL alike.
Each SYMBOL or EDITSYMBOL line starts a new symbol; the other
records belong to the most recent one.
Every created or edited symbol is one undo step and marks the library
as modified; nothing is saved - the user saves the library.
Returns:
str: JSON object with created and edited counts, a failed name list
and problems (e.g. a pin number not in the symbol, an unknown
IEEE symbol or justification)get_symbol_primitives tool
Read the graphic primitives of symbols in a schematic library (.SchLib).
Two modes:
- symbol_name omitted: inventory of every symbol in the library with
per-type primitive counts (pins, rectangles, lines, polylines,
polygons, arcs, ellipses, beziers, labels, ...). Use this to survey
what drawing features a library's symbols require.
- symbol_name given (exact match, case-insensitive): full geometry dump
of that symbol - every primitive with coordinates in mils, plus pin
details (number, name, electrical type, orientation, length,
owner_part_id). Use this as the reference/spec when recreating or
validating a symbol.
Args:
library_path (str, optional): Full path to the .SchLib file to open.
Omit to use the schematic library currently focused in Altium.
symbol_name (str, optional): Exact symbol (LibReference) name to dump.
Returns:
str: JSON object - inventory mode: {library_name, symbol_count,
symbols: [{name, description, part_count, <type counts>}]};
dump mode: {library_name, symbol_name, description, part_count,
comment: {text, visible}, parameters: [{name, value, visible,
x, y, justification, autoposition, font: {name, size}}],
primitives: [...]} - x and y are where Altium holds the
parameter now. Pins also carry
description, symbol_inside, symbol_inside_edge,
symbol_outside_edge and symbol_outside (IEEE symbol names as
PINSYMBOL takes them), their parameters [{name, value}]
when they have any, and functions ["ETH1_MDIO", ...] (the
Functions list, as PINFUNC sets it) when they have anyget_all_nets tool
Return every unique net name in the active PCB document.
Returns
-------
str :
A JSON array of net names, e.g. ["GND", "VCC33", "USB_D+", ...]create_net_class tool
Create a new net class and add specified nets to it
Args:
class_name (str): Name of the net class to create or modify
net_names (list): List of net names to add to the class
Returns:
str: JSON object with the result of the operation. nets_added counts
the nets that were not in the class before; names the board has no
net for are listed in nets_not_found and not added.set_component_position tool
Set a component's absolute position in the PCB layout
Args:
cmp_designator (str): Designator of the component to position (e.g., "R1", "C5", "U3")
x (float): Absolute X position in mils
y (float): Absolute Y position in mils
rotation (float): Rotation angle in degrees (0-360), use -1 to keep current rotation
Returns:
str: JSON object with the result of the position operationmove_components tool
Move components by RELATIVE offset from their current position (not absolute positioning)
IMPORTANT: This moves components BY the offset amount, not TO a position.
For absolute positioning, use set_component_position instead.
Args:
cmp_designators (list): List of designators of the components to move (e.g., ["R1", "C5", "U3"])
x_offset (float): X offset distance in mils (positive = right, negative = left)
y_offset (float): Y offset distance in mils (positive = up, negative = down)
rotation (float): New absolute rotation angle in degrees (0-360), if 0 the rotation is not changed
Returns:
str: JSON object with the result of the move operationplace_components tool
Place multiple components at absolute positions in a single Altium transaction.
This is the batch version of set_component_position - prefer it whenever
placing more than one component, since every tool call is a full round
trip into Altium. The whole batch is one undo step.
Coordinate conventions: x/y are in mils relative to the board origin;
rotation is in degrees counterclockwise.
Args:
placements (list): One dict per component:
- designator (str, required): e.g. "R1"
- x (float, required): absolute X position in mils
- y (float, required): absolute Y position in mils
- rotation (float, optional): absolute rotation in degrees (0-360).
Omit (or pass -1) to keep the current rotation.
- layer (str, optional): "top" or "bottom" to set the board side
(the footprint is mirrored when flipped). Omit to keep the
current side.
- locked (bool, optional): lock (true) or unlock (false) the
component; omit to leave it as it is.
- designator_text, comment_text (dict, optional): put the
designator or comment text at {x, y (its anchor, as get_layout
reports it), rotation, height, stroke_width, visible,
autoposition ("manual" by default, or top_left ... bottom_right
as get_layout reports it)} after the move. Omit to let it move
with the part. (set_designator_positions places by centre.)
board_path (str): Full path of the .PcbDoc; empty for the focused
board, or the one the PCB tools last used. Give it whenever more
than one board is open, so the parts move on the right one.
Example:
placements=[{"designator": "R1", "x": 1000, "y": 2000, "rotation": 90},
{"designator": "C5", "x": 1050, "y": 2000, "layer": "bottom"}]
Returns:
str: JSON object with placed_count, missing_designators, and the final
x/y/rotation/layer of each placed component as Altium reports themget_net_connections tool
Get net connectivity and airline (unrouted connection) lengths for the
nets touching the given components.
Use this to plan or score a placement: it shows every pad on each net -
including pads of OTHER components outside the given set (e.g. an input
filter the cluster must connect to) - plus the net's minimum-spanning-tree
airline length in mils. Shorter airlines on critical nets (switching
loops, input/output capacitors) mean a better placement; non-critical
nets (enables, set resistors, feedback dividers) may be lengthened to
buy routing space. Plane nets like GND have many pads and a meaningless
airline - judge them by proximity to plane connections instead.
Args:
cmp_designators (list, optional): Components whose nets to analyze
(e.g. ["U12", "R42"]). Omit to use the current Altium selection.
max_pads_per_net (int): Nets with more pads than this (e.g. GND)
return only pads belonging to the given components, plus the
total pad_count. Their airline is also skipped. Default 40.
Returns:
str: JSON object with one entry per net: pad_count,
airline_mst_mils (None for large nets), and pads
[{designator, pin, x, y}, ...] in mils relative to the board
origin. Large nets set pads_truncated=true.check_orientation tool
Advisory check: find 2-pad passives whose rotation could be improved.
For each 2-pad component in the target set, every orthogonal rotation
(0/90/180/270) is scored in place, summing one term per pad:
- routable nets (few pads): the net's total airline (MST) length with
this pad at the candidate position - so a pad that merely slides along
a pass-through flow (e.g. a bulk cap in a power chain) scores as
nearly free, while a genuine detour costs its real length
- plane nets (many pads, e.g. GND): distance to the nearest same-net
pad - a capacitor's ground-return loop is local, so proximity to the
IC's GND/thermal pad is what matters
A component is reported when a different rotation beats the current one
by at least min_improvement_mils.
This is advisory, not pass/fail: it measures geometry only and knows
nothing about net criticality. Suggestions matter for loop-critical
parts (capacitor ground returns, snubbers, input/output filters) and
should usually be ignored for parts whose orientation is electrically
arbitrary (pull-ups, strapping resistors, enables) or where a datasheet
layout recommendation says otherwise. Weigh suggestions with judgement
rather than applying them blindly. If a suggestion with
bbox_changes=true is applied (a 90-degree change alters the body
outline), re-run check_placement afterwards.
Args:
cmp_designators (list, optional): Components to check. Omit to use
the current Altium selection. Components with more or fewer than
2 pads are skipped.
min_improvement_mils (float): Only report components where the best
rotation improves the connection score by at least this many
mils (default 25).
Returns:
str: JSON object with checked_count and suggestions, each having
designator, current_rotation, suggested_rotation,
improvement_mils, bbox_changes, and a per-pad breakdown of
nearest same-net distances at the current vs suggested rotation.check_placement tool
Verify component placement: find overlaps and clearance violations.
Checks each target component against every other component on the same
side of the board. Bounding boxes (which include silkscreen) are used as
a fast prefilter; close pairs are then measured precisely with Altium's
primitive-to-primitive distance, so reported distances are true minimum
distances between any primitives (pads, silk, etc.) of the two parts.
Run this after placing components - a screenshot is not verification.
Args:
cmp_designators (list, optional): Components to check (e.g. ["U12", "R42"]).
Omit to check the components currently selected in Altium.
clearance_mils (float): Minimum allowed primitive-to-primitive distance
in mils (default 6). Pairs closer than this are reported.
Returns:
str: JSON object with checked_count, violation_count, and a violations
list. Each violation has a/b designators, type
("bounding_box_overlap" = the parts' outlines intersect, or
"clearance" = distance below threshold), distance_mils (0 =
touching/overlapping copper or silk), overlap sizes when boxes
intersect, and the other part's x/y position. An empty violations
list means the placement is clean at the given clearance.check_routing tool
Check the routed copper of the focused PCB for segments that are not 0,
45 or 90 degrees, and for right-angle and acute corners.
Run this after changing tracks or vias - a screenshot does not show a
stub that is 2 degrees off 45. Such stubs come from a diagonal whose end
was snapped to a grid on its own, or from a track end dragged along
when a via or component moved. Only tracks with a net that are not part
of a component or polygon pour count. A corner is where exactly two
track ends of one net meet on one layer; under a via or pad it is not
a corner.
Args:
nets (list, optional): Check only these nets (exact names, any case).
angle_tolerance_deg (float): How far a segment may be from a
multiple of 45 degrees (default 0.1).
max_findings (int): Most entries listed per kind (default 50). The
counts always cover every segment.
Returns:
str: JSON with clean (true when nothing was found), the segment
count, segment_angles (orthogonal / 45 / off-angle counts),
corner_turns (straight / 45 / 90 / acute counts), and the
off_angle segments and sharp_corners: net, layer, positions in
mils relative to the board origin, angle or turn in degrees.place_polygon_pour tool
Add a polygon pour (copper area, e.g. a ground pour) to a PCB and pour it.
The pour keeps the board's clearance rules from other nets and joins
same-net pads and tracks as the polygon connect rule says. Cut holes in
it with place_cutout.
Args:
outline (list): Corners [[x, y], ...] in mils relative to the board
origin, in order around the shape (at least three; it closes by
itself). Straight edges only.
layer (str): Signal layer, by its stack name or Altium's name, e.g.
"Top Layer".
net (str): Net to pour; it must exist on the board. Empty for an
unconnected pour.
name (str): Polygon name; empty lets Altium name it.
hatch (str): "solid" (default), "hatched_45", "hatched_90", or
"none" (outline only).
pour_over_same_net (bool): Pour over same-net tracks and pads.
remove_dead_copper (bool): Remove islands not connected to the net.
track_width_mils (float): Hatch track width; 0 for Altium's default.
grid_mils (float): Hatch grid; 0 for Altium's default.
board_path (str): Full path of the .PcbDoc; empty for the focused
board, or the one the PCB tools last used.
Returns:
str: JSON with the polygon's name, layer, net and what it poured:
poured_regions, one per separate piece of solid copper, and
hatch_tracks for a hatched pour. When nothing was poured it
says why it may be: no room, or every piece touched nothing on
its net and was removed as dead copper.place_cutout tool
Add a cutout to a PCB: a hole in polygon pours, or in the board itself.
kind "polygon" keeps polygon pours out of the area on one signal layer
(or on every signal layer with layer "all"), as Altium's Polygon Pour
Cutout does. kind "board" cuts the area out of the board (a slot or
opening). Either way the polygons the cutout overlaps are repoured.
Args:
outline (list): Corners [[x, y], ...] in mils relative to the board
origin, in order around the shape (at least three).
kind (str): "polygon" (default) or "board".
layer (str): For a polygon cutout, the signal layer ("Top Layer",
a stack name) or "all". Ignored for a board cutout.
board_path (str): Full path of the .PcbDoc; empty for the focused
board, or the one the PCB tools last used.
Returns:
str: JSON with how many cutout regions were added and how many
polygons were repoured.repour_polygons tool
Repour polygon pours on a PCB: all of them, or the ones the filters pick.
Repour after moving parts, tracks or vias through a pour, or after
changing clearance or polygon connect rules; Altium does not repour by
itself. The whole repour is one undo step.
Filters combine; with none, every polygon on the board is repoured.
Args:
names (list): Polygon names, any case. Names need not be unique (a
"GND" pour on each layer is common), so add layer to pick one.
net (str): Only polygons on this net.
layer (str): Only polygons on this signal layer, by stack name or
Altium's name ("Top Layer").
area (list): [x1, y1, x2, y2] in mils from the board origin: only
polygons overlapping it, e.g. around an edit. Overlapping, so a
whole-board pour counts for any area on it.
include_shelved (bool): Also repour shelved polygons, which
unshelves them. By default they are left shelved and listed.
board_path (str): Full path of the .PcbDoc; empty for the focused
board, or the one the PCB tools last used.
Returns:
str: JSON with how many polygons were repoured and, for each, its
name, layer, net and poured_regions (separate pieces of
copper) and hatch_tracks. shelved_skipped lists the shelved
polygons that matched and were left alone.delete_pcb_objects tool
Delete copper from a PCB: tracks, arcs, vias, polygon pours, copper
regions, fills or pour cutouts. Use it to rip up routing.
Objects are picked by every filter given: kinds, net, layer and area,
or a group's copper by designators. At least one must narrow the match;
deleting all the copper on the board is refused. Only copper is ever
touched: never pads, anything belonging to a component, keepouts, or
objects on other layers (board outline, silkscreen, mechanical). The
copper a pour poured goes with its pour. Locked objects are left alone
and listed, unless include_locked. One undo step in Altium. Use dry_run
first to see what would go.
Deleting copper inside a pour leaves the pour as it was: repour it.
Remove a via stitching group with Altium's own command rather than
here, so the group goes too.
Args:
kinds (list): Some of "track", "arc", "via", "polygon", "region",
"fill", "cutout" (a pour cutout). Empty: all but cutouts.
net (str): Only objects on this net.
layer (str): Only objects on this copper layer, by stack name or
Altium's name ("Top Layer"); a via matches every layer it spans.
area (list): [x1, y1, x2, y2] in mils from the board origin; only
objects lying inside it.
designators (list): Rip up a group's copper, as get_layout lists it:
what lies inside the group's extent (grown by margin_mils, or
area when given) plus the copper of its own nets (nets with no
pad on another part) wherever it runs.
margin_mils (float): See designators (default 40).
include_locked (bool): Delete locked objects too.
dry_run (bool): List what matches without deleting.
board_path (str): Full path of the .PcbDoc; empty for the focused
board, or the one the PCB tools last used.
Returns:
str: JSON with matched, deleted, the first 50 objects (kind, net,
layer, position in mils), and locked_skipped with the first
20 locked objects left alone.modify_pcb_objects tool
Change copper on a PCB: the width of tracks and arcs, the size of vias,
the net, or the layer.
Objects are picked as for delete_pcb_objects, and at least one filter
must narrow the match. Each change applies where it makes sense:
width_mils to tracks and arcs, via_diameter_mils and via_hole_mils to
vias, new_layer to tracks, arcs, fills and regions, new_net to all ("" removes
the net). A via whose hole would not fit inside its diameter is left as
it is and counted. A polygon given another net pours again. Locked
objects are left alone unless include_locked. One undo step in Altium.
Changed copper inside a pour leaves the pour as it was: repour it, and
run DRC after changing widths or via sizes.
Args:
kinds, net, layer, area, designators, margin_mils, include_locked:
The filters, as for delete_pcb_objects.
width_mils (float): New width of tracks and arcs.
via_diameter_mils, via_hole_mils (float): New via size; either alone
is checked against each via's other size.
new_net (str): New net; "" removes the net; leave out to keep it.
new_layer (str): Copper layer to move tracks, arcs, fills and
regions to.
dry_run (bool): List what matches without changing it.
board_path (str): Full path of the .PcbDoc; empty for the focused
board, or the one the PCB tools last used.
Returns:
str: JSON with matched, changed, unchanged (matched objects none of
the changes applies to), vias_left_as_hole_would_not_fit,
locked_skipped, and the first 50 objects as they were.query_objects tool
Find PCB objects with Altium's own query language, as the PCB Filter
panel and rule scopes use it.
Examples: "IsVia And InNet('GND')", "IsTrack And OnTopLayer And
(Width < 6mil)", "InComponent('U1') And IsPad", "IsPolygon",
"InNetClass('Power')". A component is found by Name ("IsComponent And
(Name = 'U1')"; there is no Designator property) and a pad by its full
name ("IsPad And (Name = 'U1-3')"). Text is quoted with ' and compared
as text: Name = 1 fails where Name = '1' works. Put each comparison in
brackets: IsComponent And Footprint = 'X' is read as
(IsComponent And Footprint) = 'X' and fails.
An expression Altium cannot read or evaluate comes back as an error with
Altium's message; the dialog it raises is answered, so Altium is not
left waiting.
Layers are named as the board names them in its layer stack
(OnLayer('GND1')); Altium's generic names ('Mid Layer 1', 'Mechanical
17') given to OnLayer(), ExistsOnLayer() or Layer = are translated to
the board's, so both work. Each object gives both: layer (generic) and
layer_name (the board's, when it has its own).
The engine has no position properties (X, Y): give a box as area
instead (clamped to Altium's design space, +-100,000 mil). It keeps the
objects whose bounds touch the box, so a pour larger than the box is
kept wherever its copper is.
Give sizes with a unit (6mil, 0.15mm). The engine reads bare numbers in
its own unit, which is not always the board's display unit, and a unit
written inside the query is a syntax error; so each value with a unit is
converted to the unit the engine uses on this board before the query
runs. Decimals take a dot. Quoted text is sent as written, units and
commas included (InNet('D0,1'), Comment = '4.7uF 2.2mm').
The engine works through the selection, so the user's selection is
selected again afterwards, also after a query Altium could not
evaluate; objects of kinds the PCB Selection Filter (Properties panel)
leaves out cannot be selected by a script and stay unselected. A filter
applied in the PCB Filter panel is cleared: a script cannot read it back
to restore it.
Args:
expression (str): The query.
area (list): Only objects touching [x1, y1, x2, y2], from the board
origin in unit. Default the whole board.
unit (str): "mil" (default) or "mm", for area.
limit (int): How many objects to list in full, 0 to 1,000,000
(0 lists none); matched counts all.
board_path (str): Full path of the .PcbDoc; empty for the focused
board, or the one the PCB tools last used.
Returns:
str: JSON with matched, by_kind counts, and the objects: kind, name
(component designator, pad, polygon, rule, net), net, layer,
layer_name and bounds in mils from the board origin.
expression_run is what the engine ran.
copper_polygons_without_net counts matched pours with no net,
which InNet() cannot find.which_rule tool
Which design rule applies to a PCB object, or between two, and whether
they pass it: the rule the DRC picks (FindDominantRuleForObject or
...ForObjectPair) and the DRC's own test of it (Rule.ActualCheck, on
a pair both ways round), so net scope and the clearance matrix count as
they do in a DRC.
Each object is a query expression (as for query_objects) that must match
exactly one object, e.g. "IsPad And (Name = 'U1-3')". The engine has no
X or Y, so narrow one down by position with area_a / area_b, e.g.
object_a="IsVia And InNet('GND')", area_a=[1245, 795, 1255, 805].
Args:
object_a (str): Query expression for the object.
object_b (str): Query expression for the other object of a pair
rule; leave empty for a one-object rule (width, hole_size,
routing_via, solder_mask_expansion, paste_mask_expansion,
plane_connect).
rule_kind (str): clearance (default), short_circuit, hole_to_hole,
silk_to_silk, silk_to_mask, component_clearance, polygon_connect
(pairs); or one of the one-object kinds above.
area_a, area_b (list): Only objects touching [x1, y1, x2, y2] from the
board origin, in unit, count for object_a / object_b.
unit (str): "mil" (default) or "mm", for the areas.
board_path (str): Full path of the .PcbDoc; empty for the focused
board, or the one the PCB tools last used.
Returns:
str: JSON with the object(s), distance_mils (edge to edge) for a
pair, and the rule: name, descriptor, priority, enabled,
scopes, gap_mils for clearance, and passes (Altium's own check)
for the kinds the DRC tests.route_track tool
Add a routed track through waypoints on the focused PCB, every segment
exactly 0, 45 or 90 degrees.
Between two waypoints that are not in line, the track takes a straight
leg and a 45 degree diagonal. The diagonal is computed from its own
start point, so its x and y runs are equal: nothing is snapped on its
own, which is what leaves stubs a few degrees off 45. Use this instead
of placing track segments from run_altium_script, and run
check_routing afterwards. It adds tracks only: no vias, and no DRC.
Args:
net_name (str): Net of the track; it must exist on the board.
layer (str): Layer name as get_component_pins and check_routing
report it, e.g. "Top Layer" or "Bottom Layer".
width_mils (float): Track width in mils.
points (list): Waypoints [[x, y], ...] in mils relative to the
board origin, at least two: usually a pad centre, any bends,
and the far pad or via centre.
diagonal_first (bool): Put the diagonal at the start of each
stretch instead of its end (default: straight, then diagonal).
corner_chamfer_mils (float): Cut each right-angle corner between two
straight legs with a 45 degree segment, setting back this far on
each leg (at most half the shorter leg). 0 leaves them square.
dry_run (bool): Only compute and return the segments.
Returns:
str: JSON with the segments in mils ([x1, y1, x2, y2]) and, unless
dry_run, how many tracks were added.auto_place_silkscreen tool
Bulk-place designators with the Silkscreen Auto Placer script - step 1 of
silkscreen cleanup. Then finish by hand with the other silkscreen tools.
Runs a headless port of the AutoPlaceSilkscreen script inside Altium. For
every part, smallest first, it tries the enabled autopositions on an
offset grid with shrinking text, then a retry pass (rotation flip, wider
grid) and a 2nd-pass "wiggle" search up to 100 mil out. It avoids pads,
component bodies, other silk and (optionally) vias, and keeps the Board
Outline Clearance rule's distance from the board edge. Typically 80-95%
of designators end up placed; the rest are handled per failed_action.
Everything is one undo step. A whole-board run moves every designator:
ask the user to save the board first.
It is fast and good at the bulk, but it does not judge readability:
labels can land far from their part (2nd-pass label blocks), next to a
neighbour, or over open vias when avoid_vias is off. Always follow up:
1. check_silkscreen - lists what needs work (failed designators, DRC,
ambiguous or distant labels).
2. view_silkscreen / get_designator_options - look at each problem area
and find legal spots.
3. set_designator_positions - place them (dry_run first for neighbours).
Options default to the settings last saved by the script's GUI
(AutoPlaceSilkscreen.ini) when use_saved_settings is on, else the GUI's
defaults. Any argument given here overrides them.
Args:
designators (list, optional): Only place these designators. Omit for
the whole board (or the selection with selected_only).
selected_only (bool): Place only the components selected in Altium.
failed_action (str): What to do with designators that could not be
placed: "center" (centre them on their part, where
check_silkscreen flags them), "hide", or "restore" (put them back
where they were).
avoid_vias (bool): Treat vias as obstacles.
rotation_strategy (str): "component", "horizontal", "along_side",
"along_axis", "along_pins" or "klc" (KLC style).
positions (list): Autopositions to try, in order: TopCenter,
CenterRight, BottomCenter, CenterLeft, TopLeft, TopRight,
BottomLeft, BottomRight.
try_altered_rotation (bool): Also try the text turned 90 degrees.
second_pass (bool): Run the wider "wiggle" search for failures.
unhide_all (bool): Show hidden designators first so they get placed.
auto_hide (list): Designator prefixes to hide instead of placing,
e.g. ["TP", "MT", "FID"]; [] hides none.
allow_under (list): Designators whose bodies silk may cover.
text_height_mils (float): Fixed text height; 0 = size from the part
(shrinks to 25 mil when needed).
stroke_width_mils (float): Fixed stroke width; 0 = from the height.
position_delta_mils (float): Extra gap between autoposition and part.
component_outline_layer (str): Mechanical layer holding component
bodies (default "Mechanical 13" or a "Component Outline" layer).
use_saved_settings (bool): Start from the GUI's saved settings.
Returns:
str: JSON with placed/failed counts per pass, the failed designators,
the settings used and the next step.check_silkscreen tool
Find the designators that need work. Start and finish silkscreen cleanup
with this.
Two parts:
- drc: each designator is tested with Altium's own Silk To Silk
Clearance, Silk To Solder Mask Clearance and Board Outline Clearance
rules (Rule.ActualCheck, the test a batch DRC runs) against nearby
silk, pads, vias, mask objects and the board edge. Ground truth for
fabrication.
- quality: problems DRC does not flag - text far from its part or closer
to another part of the same type, over another part's body or under its
own (e.g. left on top of its part by an auto-placer), off the board, or
rotated to read upside down.
needs_attention lists every designator with either kind of problem;
hidden lists designators whose display is turned off.
Args:
designators (list, optional): Designators to check. Omit for all.
preview (bool): Also return a whole-board view with the problem
designators in red (default False).
Returns:
JSON with needs_attention, drc and quality (both grouped by
designator), hidden, plus optional view image(s).view_silkscreen tool
Look at the silkscreen around some designators or in a region.
Renders one board side cleanly - no Altium UI, no copper clutter - with a
grid labelled in mils (board-origin coordinates, the same ones
set_designator_positions takes), so a free spot can be read straight off
the image. Shows solder mask openings, silk, part names at their centres,
every designator box, and marks designators whose current spot has a
problem in red. The designators asked about are cyan with a line to
their part.
Uses the board snapshot (refreshed by check_silkscreen, updated by
set_designator_positions, at most 5 minutes old). Pass refresh=True after
editing the board by hand in Altium.
Args:
designators (list, optional): Zoom to these parts and highlight them.
region (list, optional): [x_min, y_min, x_max, y_max] in mils to show
instead. Omit both for the whole board.
side (str, optional): "top" or "bottom". Default: the side of the
first designator, else top.
grid_mils (float): Grid spacing; 0 picks one to suit the zoom.
refresh (bool): Re-export the board from Altium first.
Returns:
JSON (view bounds, grid, legend, problems of the designators in view)
plus the image.get_designator_options tool
Legal spots for designators, ranked, drawn as numbered boxes.
For each designator: its current spot and what is wrong with it, then up
to `count` distinct legal positions around its part - clear of silk, solder
mask openings, untented vias, the board edge and every other designator
where it is now, readable, and nearer its own part than any other part of
the same type. Ranked by: close to the part, above > left/right > below,
text along the part's long axis, centred. Pick one (or use the image to
judge a better spot) and apply it with set_designator_positions using the
option's x, y and rotation.
The designators asked about are not obstacles to each other: when placing
neighbours, check the chosen spots together with
set_designator_positions(dry_run=True) first. When a designator has no
legal spot, blocked_by says what is in the way: ask again together with
the neighbouring designators (so they can move to make room), allow
smaller text (min_height_mils), or place its row's designators as a
block with get_label_block_options. Do not hide designators to get rid
of problems; only mounting holes and fiducials go without one.
Args:
designators (list): Designators to find spots for.
count (int): Options per designator (default 5).
max_gap_mils (float): Furthest the text may sit from its part's pads
and silk (default 50).
min_height_mils (float): Also offer smaller text, down to this height,
in 5 mil steps (0 = current size only).
refresh (bool): Re-export the board from Altium first.
Returns:
JSON per designator (current spot + problems, options with n, x, y,
rotation, side, gap_mils and height when reduced, or blocked_by) plus
an image per board side with the options numbered.set_designator_positions tool
Place designators - by coordinates or relative to their part - and get a
verdict for each.
Each placement is either
- absolute: x, y = centre of the text box in mils (board origin), as read
off view_silkscreen or taken from get_designator_options, or
- relative: side = "above" | "below" | "left" | "right" | "inside" of its
own part, with gap (mils from the part's pads/silk; default just clear
of them) and offset (slide along that side, +x or +y).
Optional on both: rotation (0/90 top, 0/270 bottom read correctly;
default keeps a readable current rotation), height and stroke_width
(mils), visible (show/hide - hide only mounting holes and fiducials;
designators with no room go in a label block, see
get_label_block_options). A placement with only visible (or only
rotation/height) keeps the current centre.
dry_run=True changes nothing: every placement is checked against silk,
mask openings, the board edge, other designators where they are now and
each other, plus placement quality. Use it to test a set of neighbours
together before applying.
Otherwise all moves are one undo step, and with verify (default) each
moved designator is then checked with Altium's own silk rules and for
quality. ok=true means clean. The moves only go to the board the
snapshot was read from: if another PCB has been focused since, nothing
moves and the error names both boards.
Args:
placements (list): Dicts with designator plus x/y or side (gap,
offset), and optional rotation, height, stroke_width, visible.
dry_run (bool): Only check the placements.
verify (bool): After moving, run Altium's silk DRC on the moved
designators (default True).
Returns:
str: JSON with one verdict per designator: final x, y, rotation,
ok and problems.get_label_block_options tool
Place a row of parts' designators together as a block, when they do not
fit next to their parts one by one. Use this instead of hiding
designators (only mounting holes and fiducials go without one).
Parts in a row get their designators in a row too, in the same order,
even some way off. Give one designator to use the whole row it belongs
to (parts side by side along x or y, similar size across the row, gaps
up to 50 mil), or list the parts yourself. For a block of just one part
(its label alone, linked to it), give it with whole_row=False.
Each option is a block of labels - across the row (in line with each
part when the pitch allows, else side by side) or end to end along it -
clear of silk, mask openings, the board edge, other designators and part
bodies, plus a link when it is not right against the row:
- leader: a silk line with an arrowhead from the block to the parts;
- index: matching markers - a capital letter in a circle (then square,
then triangle) - next to the block and next to the parts.
Ranked: no link, then leader, then index; nearer and larger text first.
Apply one with place_label_block.
Args:
designators (list): One designator (its row is used) or the block's parts.
count (int): Options to return (default 3).
min_height_mils (float): Smallest text allowed (default 25).
max_distance_mils (float): Furthest the block may sit from the parts (default 500).
link (str): "auto" (cheapest), "none", "leader" or "index".
whole_row (bool): With one designator, use its whole row (default)
or just that part.
refresh (bool): Re-export the board from Altium first.
Returns:
JSON with the parts in order and the numbered options, plus an image
per option (block labels cyan with lines to their parts, link magenta).place_label_block tool
Apply a label block from get_label_block_options: move the parts'
designators into the block (shown, at the block's text size) and draw
its link on the silkscreen, then check both with Altium's rules. An
earlier block of any of these parts is replaced (its link removed).
Args:
designators (list): The same designators given to get_label_block_options.
option (int): Which option (default 1).
whole_row (bool): As given to get_label_block_options.
Returns:
JSON: the block's parts, link and marker, ok, and any Altium
violations of the labels or the link graphics.remove_label_block tool
Remove the label block of these parts: its link graphics (leader or
index markers) are deleted; the designators stay where they are, ready
to be placed again.
Args:
designators (list): Any of the block's parts.
Returns:
JSON with the removed block's parts and link.place_vias tool
Add vias to a PCB: stitching, fan-out, or a via at the end of a track.
Args:
vias (list): Via positions in mils relative to the board origin,
each [x, y] or an object {"x": .., "y": .., "net": ..,
"diameter_mils": .., "hole_mils": .., "start_layer": ..,
"end_layer": ..} whose keys override the defaults below for
that via.
diameter_mils (float): Via pad diameter.
hole_mils (float): Drill diameter, smaller than diameter_mils.
net (str): Net of the vias; it must exist on the board. Empty for
vias without a net.
start_layer (str): Layer the via starts on, e.g. "Top Layer".
end_layer (str): Layer it ends on, e.g. "Bottom Layer". Set both for
a blind or buried via.
board_path (str): Full path of the .PcbDoc; empty for the focused
board, or the one the PCB tools last used.
Every net and layer is checked before anything is added, so a bad entry
adds nothing. Run run_drc afterwards: a via is not checked against
clearance when it is placed.
Returns:
str: JSON with how many vias were added.get_layout tool
Read the layout of a group of components or of an area: the components'
placement and the copper around them (tracks, arcs, vias, fills, copper
regions and polygon pours, each pour with its full outline, arc edges
included, and its pour settings). Read-only.
The result is in exactly the form place_copper takes, so it can be
edited and placed again, on this board or moved with place_copper's
transform (to repeat a channel, for example). The components come in
place_components' form.
Args:
designators (list): Components to read, e.g. ["U5", "C13", "Y1"].
Without an area, the area is their extent (pads and bodies)
grown by margin_mils.
area (list): [x1, y1, x2, y2] in mils from the board origin. With
no designators, the components wholly inside it are listed.
margin_mils (float): How far the area reaches beyond the components
(default 40).
include_touching (bool): Also list copper that only reaches into the
area, such as a track leaving the group. By default only copper
wholly inside the area is listed: the group's own routing.
include_local_nets (bool): With designators, also list the copper of
their own nets (nets with no pad on any other part) wherever it
runs, such as a route between two of them that leaves the area
(default true).
include_pads (bool): Also list every pad reaching into the area
(designator, pad, x, y, layer, shape, size [x, y], rotation,
hole, net), e.g. to see what new copper must keep clear of.
board_path (str): Full path of the .PcbDoc; empty for the focused
board, or the one the PCB tools last used.
out_file (str): Write the layout to this JSON file and return only a
summary; for large areas.
Never listed: copper that belongs to a component or that a pour poured
(the pour itself is), keepouts, and objects on non-copper layers
(counted in skipped).
To see everything in a box, on any layer and with refs that clearance
and drag_copper take, use objects_in_area instead; get_layout is for
reading copper to edit and place again.
Returns:
JSON: area; components (designator, x, y, rotation, layer, locked,
footprint, designator_text and comment_text: {x, y, rotation,
height, stroke_width, visible, autoposition}); tracks (net, layer,
width, start, end); arcs (net, layer, width, center, radius,
start_angle, end_angle: counter-clockwise from start to end); vias
(net, x, y, diameter, hole, start_layer, end_layer); fills; regions;
cutouts (layer, outline); pours (name, net, layer, hatch, pour_over,
remove_dead_copper, remove_islands, island_area_sq_mils,
remove_necks, neck_width_mils, grid, track_width, arc_approximation,
pour_index, locked, obey_cutouts, optimal_void_rotation, outline:
vertices {x, y} with "arc" {center, radius, start_angle, end_angle}
when the edge to the next vertex is an arc); counts and
missing_designators. All in mils and degrees.place_copper tool
Add copper to a PCB in one undo step: tracks and arcs at any angle, vias,
fills, copper regions and polygon pours (arc edges, island and neck
removal, pour order). Everything is checked first (each net must exist,
each layer must be a signal layer), so a bad entry adds nothing. Pours go
in last, in pour_index order, and are poured around the copper added
with them. The nets the copper is on are analyzed afterwards, so the
ratsnest is current (this can join straight track segments that continue
each other; the copper stays the same). Run run_drc or
get_unrouted_connections afterwards.
Each list takes entries in get_layout's form (mils, degrees):
tracks: {net, layer, width, start: [x, y], end: [x, y]}
arcs: {net, layer, width, center: [x, y], radius, start_angle,
end_angle} (counter-clockwise from start to end)
vias: {net, x, y, diameter, hole, start_layer, end_layer}
(layers default to Top Layer and Bottom Layer)
fills: {net, layer, corner1: [x, y], corner2: [x, y], rotation}
regions: {net, layer, outline: [[x, y], ...]}
cutouts: {layer, outline} a polygon pour cutout, on a signal layer
or "Multi Layer" (all of them); pours with obey_cutouts
leave it free
pours: {net, layer, outline, name, hatch ("solid", "hatched_45",
"hatched_90", "vertical", "horizontal", "none"), pour_over
("same_net", "same_net_polygons", "none"),
remove_dead_copper, remove_islands (below island_area_sq_mils,
default 2500), remove_necks (narrower than neck_width_mils,
default 5), grid, track_width, arc_approximation,
pour_index, locked, obey_cutouts (default true),
optimal_void_rotation (default false)}
outline vertices are [x, y] or {x, y, arc: {center, radius,
start_angle, end_angle}} for an arc edge to the next vertex.
net "" is no net. Coordinates are mils from the board origin.
Args:
tracks, arcs, vias, fills, regions, cutouts, pours (list): Copper
to add.
layout (dict): A whole get_layout result; its copper lists are added
too (its components are not moved: use place_components).
transform (dict): Move everything: {"dx", "dy", "rotation" (degrees,
about "about": [x, y], default the origin), "mirror" (mirror x
before rotating)}. Fills only shift.
rename_nets (dict): {old net: new net}, e.g. to repeat a channel.
board_path (str): Full path of the .PcbDoc; empty for the focused
board, or the one the PCB tools last used.
Returns:
JSON: counts added (tracks, arcs, vias, fills, regions, cutouts) and each pour
with the pieces of copper it poured (0 means it poured nothing), or
the problems that stopped it.get_unrouted_connections tool
List the connections still to be routed (Altium's ratsnest lines): for a
group of components, some nets, or the whole board. Unlike run_drc it
has no 500-violation limit and needs no DRC run, so it is the quick way
to see what a group still lacks after placing and routing it.
Args:
designators (list): Components whose nets to check. Their pads name
the ends of each connection (from_pad, to_pad), and unless area is
given, the area is their pads' extent grown by margin_mils.
nets (list): Nets to check (exact names, any case). With neither
designators nor nets, every net.
area (list): [x1, y1, x2, y2] in mils from the board origin; each
connection says whether both its ends lie in it (inside).
margin_mils (float): See designators (default 40).
max_connections (int): Most connections listed (default 200); the
counts cover them all.
board_path (str): Full path of the .PcbDoc; empty for the focused
board, or the one the PCB tools last used.
With designators, only connections that end at one of their pads or lie
wholly inside the area are listed: a group's own connections and the
ones leaving it, not the rest of a board-wide net such as GND.
Altium does not update its ratsnest after copper added by a script, so
the nets are analyzed first. Analyzing can join straight track segments
that continue each other into one (the copper stays the same), as
Altium does after interactive routing.
Returns:
JSON: connection_count, inside_count (both ends in the area),
by_net counts, area, and connections (net, from, to, from_pad,
to_pad, length in mils, inside), longest first.route_connections tool
Route unrouted connections automatically: a maze router finds a path for
each connection, every segment 0, 45 or 90 degrees, keeping the clearance
from other nets' copper and changing layer through a via where a route
needs it. For a group's local routing after it is placed (and fanned out
with fanout_pads). Each net gets the preferred width of its width rule
(the minimum where the preferred width finds no path) and the gap of
its clearance rule, unless width_mils or clearance_mils is given. Wider
nets are routed first, then shortest first; each route becomes an
obstacle for the next. Polygon pours are not obstacles: they pour again
around new copper (repour_polygons). Everything is added in one undo
step; check with run_drc and get_unrouted_connections.
Args:
designators (list): Route the connections of these components that
lie wholly inside their area (their pads' extent, as
get_unrouted_connections gives it); include_leaving adds those
leaving the group.
nets (list): Route the connections of these nets (inside area when
given).
area (list): [x1, y1, x2, y2] in mils from the board origin.
layers (list): Layers routes may use, e.g. ["Top Layer"] (default)
or ["Top Layer", "Bottom Layer"]; with more than one, vias
(through, Top to Bottom) change layer.
width_mils (float): One width for every net, instead of the rules.
clearance_mils (float): Gap to other nets' copper, instead of the
largest clearance rule gap of the nets routed.
via_diameter_mils, via_hole_mils (float): Size of a layer-change via.
grid_mils (float): Routing grid (default 2.5); finer finds paths
between fine-pitch pads but is slower.
include_leaving (bool): See designators.
max_connections (int): Most connections routed in one call.
dry_run (bool): Find the routes and return them without adding them.
board_path (str): Full path of the .PcbDoc; empty for the focused
board, or the one the PCB tools last used.
Returns:
JSON: routed and failed connections (net, from, to, pads, width, and
why a route failed), tracks and vias added, the widths used per
net, and the connections still unrouted afterwards. With dry_run,
the tracks and vias themselves.fanout_pads tool
Fan out pads: a short track from each pad to a via next to it, e.g. to
take an IC's ground and power pads down to their planes, or to free a
pad for routing on another layer. Each via goes outward from the
component first (then the other 45 degree directions), as near as
clearance_mils from other nets' copper allows, within max_distance_mils.
Pads that already have a track or via on them are left alone. One undo
step; vias are through (Top to Bottom).
Args:
designators (list): Components whose pads to fan out.
nets (list): Only pads on these nets, e.g. ["GND", "3V3"].
pads (list): Only these pads, as "U1-5" or pad names.
width_mils, clearance_mils (float): Track width and gap to other
nets' copper. By default each net's width rule (its preferred
width, but no wider than the pad and never below the rule's
minimum) and the largest clearance rule gap of the nets.
via_diameter_mils, via_hole_mils (float): Via size.
max_distance_mils (float): Farthest a via may sit from its pad's
centre (default 80).
grid_mils (float): Grid for the clearance check (default 2.5).
dry_run (bool): Return the vias and tracks without adding them.
board_path (str): Full path of the .PcbDoc; empty for the focused
board, or the one the PCB tools last used.
Returns:
JSON: fanned out pads with their via positions, pads skipped (and
why), and the counts added.objects_in_area tool
List the board objects in a box: tracks, arcs, vias, pads, fills,
regions, polygons, texts and components, with their layer, net, owner and
geometry.
Each object has a "ref" that clearance and drag_copper take to find it
again (opaque: pass it on as is). To read a group's copper in the form
place_copper takes, to edit and place it again, use get_layout instead.
Regions, tracks and polygons are matched by their real shape, so a
board-sized pour is listed only where its copper reaches the box: a
polygon when one of its poured regions does (or, with none, such as a
hatched or unpoured one, its outline). A pour's copper (a region with
in_polygon) carries its polygon's name, net and layer.
Args:
bbox (list): [x1, y1, x2, y2] relative to the board origin, in unit.
layers (list): Only these layers, by Altium's name ("Top Layer",
"Mid Layer 1", "Mechanical 1"); through vias and Multi Layer pads
are on every copper layer (not on overlay, mask or mechanical
layers), a blind via on the layers it spans. Default all.
kinds (list): Only these: track, arc, via, pad, fill, region, polygon,
text, component. Default all.
nets (list): Only objects on these nets.
unit (str): "mil" (default) or "mm", for bbox and the reply.
limit (int): At most this many objects (default 500), counted after
the filters; total says how many match (null when there are more
than Altium was asked for), and truncated whether the list was
cut.
include_hidden (bool): Also list component designators and comments
that are switched off (hidden: true). Default False.
board_path (str): Full path of the .PcbDoc; default the focused board.
Returns:
str: JSON with total, returned, truncated and objects [{kind, layer,
net, component, coordinates..., ref}]route_path tool
Route a net through waypoints, changing layer with vias, and check the
new copper against the board's rules.
Every segment is exactly 0, 45 or 90 degrees: between two waypoints not
in line the route takes a straight leg and a 45 degree diagonal (as
route_track). A waypoint with another layer than the current one puts
a via at that waypoint and the route goes on in that layer.
The new tracks and vias are then checked like check_objects_drc (own
width and hole rules; clearance, short circuit and hole to hole against
everything near), and the violations returned. Hits on pour copper are
listed apart (pour_violations): the pour has not been repoured around
the new copper yet. With undo_on_violation the route is taken off again
when there is a violation other than a pour hit, within the same undo
step, so nothing of it is left.
Refused before anything is added: a layer the board does not have, a
surface-mount pad reached on another layer than its own (that would put
a via in the pad), and a pad or via on another net, unless the
allow_ options say otherwise.
Args:
net (str): The net; it must exist on the board.
start: Where to begin: a pad as "U1-3", a pad, via or component ref
from objects_in_area, or [x, y] (then give layer).
waypoints (list): Each [x, y], [x, y, "layer"], {"x", "y", "layer"},
or a pad "J1-2" or pad/via/component ref (typically the last);
x, y from the board origin. Layer names are not case-sensitive.
layer (str): The starting layer; default the start pad's layer
(Top Layer for a through-hole pad or a point).
width (float): Track width in unit; 0 (default) takes the width
rule's preferred width for the net on each layer.
via_size, via_hole (float): Via diameter and hole; 0 takes the
routing via style rule's preferred values.
via_span (str): "through" (default: Top to Bottom) or "layers" (only
the two layers it joins).
diagonal_first (bool): Diagonals at the start of each stretch.
corner_chamfer (float): Cut right-angle corners with 45 degree
segments of this length (in unit).
unit (str): "mil" (default) or "mm".
check (bool): Check the new copper (default True).
undo_on_violation (bool): Remove the route again when the check
finds a violation (pour hits, also on a hatched pour, do not
count); success is then false. Needs check.
dry_run (bool): Only plan: the segments and vias, nothing added.
allow_via_in_pad (bool): Allow reaching a surface-mount pad on
another layer, with a via in the pad (also the last pad: the
route ends in that via).
allow_other_net (bool): Allow a pad or via of another net as start
or waypoint (listed under warnings).
board_path (str): Full path of the .PcbDoc; default the focused board.
Returns:
str: JSON with the tracks and vias added (with refs for
drag_copper and check_objects_drc), the violations, and whether
the route was removed again.check_objects_drc tool
Run the board's design rules on chosen objects only, without a batch
DRC: the vias just moved, the tracks just added.
Each copper object is checked against its own width or hole-size rule,
and against every copper object near it (tracks, arcs, vias, pads,
fills, pour copper) for the clearance, short-circuit and hole-to-hole
rules. Objects on overlay, mask and mechanical layers are not checked.
The rule is the one Altium's DRC would pick for that object or pair,
and Rule.ActualCheck, the DRC's own test, decides the violation.
Pour copper is checked as it was last poured: a via moved into a pour
shows a violation against it until the pour is repoured
(repour_polygons). Those are listed apart, as pour_violations, and so
are hits on a hatched pour's tracks.
Args:
refs (list): Objects as "ref"s from objects_in_area (or pads as
"U1-3"); not a component or polygon as a whole: give its pads or
the regions it poured.
bbox (list): And/or [x1, y1, x2, y2] from the board origin: every
copper track, arc, via, pad and fill touching it (a ref in the
box is checked once).
unit (str): "mil" (default) or "mm".
limit (int): At most this many objects from the box (default 300).
margin (float): How far to look for neighbours, in unit. Default
twice the board's largest clearance or hole-to-hole gap plus
10 mil; raise it when a rule's per-object table (track to pad,
...) has a larger entry than its gap.
board_path (str): Full path of the .PcbDoc; default the focused board.
Returns:
str: JSON with objects_checked, pairs_checked, search_margin (how
far neighbours were looked for) and the violations: rule, kind,
both objects, their distance and the rule's gap;
pour_violations those against pour copper. When nothing was
checked (no ref found, nothing in the box) success is false.clearance tool
Measure the gap between two board objects, and the clearance rule that
governs them.
Args:
object_a (str): A "ref" from objects_in_area (any kind but polygon
and component), or a pad as "U1-3".
object_b (str): The other object, likewise.
unit (str): "mil" (default) or "mm".
board_path (str): Full path of the .PcbDoc; default the focused board.
Returns:
str: JSON with distance (edge to edge, 0 when they touch), rule,
rule_gap and violates_rule (Altium's own check of that rule
for this pair), and both objectsdrag_copper tool
Move a via or a track segment and keep it connected: track ends that
meet it follow (they stretch), and a via at an end of a moved track
moves with it, its tracks on the other layers following too.
Refused when an arc ends at a moved point or a pad lies under one,
since those cannot follow; when copper of the same net meets moving copper
partway along a track (a T-junction: a branch ending partway along a moved
track, a moved end landing partway along another track, a track running
through a dragged via), since it would be left unconnected; and when any
of the copper to move or stretch is locked. The blocker names the copper.
dry_run shows what would move first. Polygon
pours are not repoured: run repour_polygons afterwards if copper changed
near one, and check_routing to confirm the connections.
Args:
object_ref (str): A via or track "ref" from objects_in_area.
dx (float): Move along x, in unit.
dy (float): Move along y, in unit.
unit (str): "mil" (default) or "mm".
dry_run (bool): Report what would move and stretch; change nothing.
board_path (str): Full path of the .PcbDoc; default the focused board.
Returns:
str: JSON with moved (the object, and vias moved with it), stretched
(track ends that followed), blocker (why it cannot be dragged)render_pcb tool
Draw a board area as a picture: copper (tracks, arcs, pads, fills,
pours), vias, overlay and the board outline, in Altium's layer colours on
black.
Drawn here from the board's objects, not captured from Altium's window:
nothing in Altium moves, zooms or comes to the front.
Args:
bbox (list): [x1, y1, x2, y2] relative to the board origin, in unit.
Default the whole board outline.
layers (list): Layers to draw, by Altium's name (case, spaces and
hyphens do not matter). Default Top Layer, Bottom Layer, Multi
Layer and Top Overlay; e.g. ["Bottom Layer", "Bottom Overlay"] for
the bottom side or ["Mid Layer 1"]. Through-hole pads and through
vias show with any copper layer, a blind via only with a layer it
spans.
dpi (float): Pixels per inch of board (default 300); lowered so the
longer side stays within 4000 pixels.
unit (str): "mil" (default) or "mm", for bbox.
board_path (str): Full path of the .PcbDoc; default the focused board.
Returns:
JSON (bbox, dpi, size, what was drawn per layer) and the PNGrender_sheet tool
Draw a schematic sheet, or part of it, as a picture: wires, buses,
junctions, component bodies with pins, net labels, power ports, ports,
sheet symbols and visible texts.
Read from the .SchDoc file, so Altium need not have it open and nothing
in Altium changes; changes not yet saved in Altium are not shown.
Args:
sheet_path (str): Full path of the .SchDoc.
bbox (list): [x1, y1, x2, y2] in sheet coordinates (Altium's origin
at the bottom left), in unit. Default everything drawn.
dpi (float): Pixels per inch of sheet (default 150); lowered so the
longer side stays within 4000 pixels.
unit (str): "mil" (default) or "mm".
Returns:
JSON (bbox in mils, dpi, size) and the PNGget_screenshot tool
Take a screenshot of exactly one thing in Altium, returned as viewable image content.
Say what to capture with `target`:
"current" the Altium window as it is now (the default).
Nothing is switched or opened.
"document" the editing area of the active document only.
"document:<name>" the editing area of that document: a file name
("PD_Mon.SchDoc") or a full path. It must already
be open unless open_if_closed is true. The document
that was active before is brought back afterwards,
and one opened for the capture is closed again
(only when it has no unsaved changes).
"dialog" the topmost Altium dialog or popup menu.
"panel:<name>" one panel, e.g. "panel:Projects", "panel:Components".
"region:x,y,w,h" a rectangle inside Altium's main window, in
pixels of a "current" capture (0,0 = its top
left corner). A region reaching outside the
window is refused: nothing outside Altium is
ever captured.
Altium comes to the front for about a second, because it only paints what
is on screen; the window that was in front then gets the foreground back.
Altium's own windows over a "current", "document" or "region" capture
are checked too: with one of its dialogs over the area nothing is
captured and the error names the dialog (see get_altium_windows and
dismiss_dialog). A floating panel there (Messages, after run_drc) gives
a warning, or is hidden for the capture with hide_floating_panels.
Args:
target (str): What to capture, see above. Default "current".
view_type (str): Old form, kept for compatibility: 'pcb' or 'sch' brings
some document of that kind to the front (opening one if none is
open) and captures the whole window. Ignored when target is given.
zoom_to (list, optional): Component designators (e.g. ["U12", "R42"]).
PCB only: Altium zooms to them before the capture. Works with
"document" / "document:<board>" and view_type 'pcb'; given on its
own it means view_type 'pcb'. "board" instead fits the whole
board outline in the view (with "document" / "document:<board>";
on its own it means target "document").
open_if_closed (bool): Let "document:<name>" open a document of the
open projects that is not open yet. Default false.
hide_floating_panels (bool): Hide Altium's floating panels that lie
over the capture while it is taken, and show them again after.
Default false: they stay, and "warnings" says how much they cover.
hide_hud (bool): Move the mouse pointer off the document view for
the capture, and back after, when it is over it: Altium draws its
heads-up coordinate display by the pointer. Default false: it
moves the user's real pointer, so only turn it on when nobody is
using the mouse.
Returns:
JSON metadata (what was captured: target, rectangle, captured_kind,
captured_document, view_type, whether anything was switched, opened or
closed, warnings, and saved_path: the PNG as a file in the server's
own folder, where the newest 50 captures are kept; copy it to use
the image elsewhere) plus the PNG image.get_altium_windows tool
List Altium's own dialogs and floating panels: the windows that can lie
over a board and end up in a screenshot, or keep Altium waiting.
Returns:
str: JSON with windows [{hwnd, class, title, rect, kind, modal}],
topmost first. kind is "dialog" or "panel" (a floating panel);
modal says the dialog blocks Altium until it is closed (see
dismiss_dialog).dismiss_dialog tool
Close an open Altium dialog, such as one left over a board that keeps
get_screenshot from capturing it, as its close box does: whatever it
asks about is left unapplied. Only Altium's own dialogs, as
get_altium_windows lists them: never its main window, a panel or a
window of another program.
No button is ever pressed: a button commits what the dialog asks about
(Save changes? No, Project Options OK, Execute Changes), and a dialog an
agent opened cannot be told from one the user is filling in.
Args:
dialog (str | int): The dialog's hwnd (from get_altium_windows) or its title
Returns:
str: JSON with closed (the dialog went away), its class and titlelayout_duplicator tool
First step of layout duplication. Selects source components and returns data to match with destination components.
Returns:
str: JSON object with source and destination component data for matchinglayout_duplicator_apply tool
Second step of layout duplication. Applies the layout of source components to destination components.
Args:
source_designators (list): List of source component designators (e.g., ["R1", "C5", "U3"])
destination_designators (list): List of destination component designators (e.g., ["R10", "C15", "U7"])
Returns:
str: JSON object with the result of the layout duplicationget_pcb_rules tool
Get all design rules from the current Altium PCB
Returns:
str: JSON array of PCB design rules: name, enabled, priority (1 is
the highest within a rule kind), descriptor, rule_kind and the
two scope expressions (filter1, filter2)run_drc tool
Run the design rule check (DRC) on a PCB and list the violations.
Runs Altium's own batch DRC with the board's rules and the options last
set in its Design Rule Checker dialog. The dialog is answered from
outside Altium: it may flash on screen. Altium writes its usual report
beside the board (or in the project's output folder) and may open it.
The violations stay on the board, marked as Altium marks them.
A cancelled check leaves no violations, exactly like a clean board, so
"ran" says whether the check really ran: the Run button was pressed and
the dialog closed. "report" (when Altium wrote one) gives the per-rule
counts and confirms it independently.
Args:
board_path (str): Full path of the .PcbDoc to check. It is opened if
needed and brought to the front. Empty: the focused board, or
the one the PCB tools last used.
rules (list): Only violations of these rules: each is a rule's own
name or a rule kind ("Clearance", "Width", "Short-Circuit",
"Un-Routed Net", "Hole To Hole Clearance", ...), whole, in any
case and with or without spaces. "Clearance" is the electrical
clearance rules only, not hole-to-hole or silk clearances. The
whole check still runs: Altium checks every enabled rule.
nets (list): Only violations with an object on one of these nets.
area (list): Only violations located in [x1, y1, x2, y2] (mils from
the board origin), by their own or an object's position.
With any filter, matching_count counts the matching violations;
listed_by_rule always counts the ones listed.
max_violations (int): How many violations to list in full.
violation_count counts every violation the check found, but
Altium stops the check at its own violation limit (500 unless
changed in its Design Rule Checker dialog); "complete": false
then says the board may have more.
Returns:
str: JSON with ran, violation_count, the violations (rule,
description, x_mils/y_mils relative to the board origin, and
the primitives involved with their net and layer), and the
report's per-rule counts.get_pcb_layer_stackup tool
Get the detailed layer stackup information from the current Altium PCB including
copper thickness, dielectric materials, constants, and heights
Returns:
str: JSON object with detailed layer stackup informationcreate_pcb_rule tool
Add a design rule to a PCB.
Values per rule_type, distances in mils:
clearance gap_mils (between scope1 and scope2)
width min_mils, max_mils, preferred_mils (all signal layers)
hole_size min_mils, max_mils
routing_via min/max/preferred_diameter_mils,
min/max/preferred_hole_mils
solder_mask_expansion expansion_mils (negative shrinks the opening)
paste_mask_expansion expansion_mils
polygon_connect connect_style ("relief", "direct", "none"), and
optionally conductor_width_mils, air_gap_mils,
entries (2 or 4)
Scopes are Altium query expressions, e.g. "All", "InNet('GND')",
"InNetClass('Power')", "IsVia", "HasFootprint('0402')". A one-scope
rule (width, hole size, via, mask, ...) uses scope1 only.
PRIORITY: Altium makes a rule added this way priority 1, the highest
of its kind, and moves the others down; a script cannot set priority.
So a new rule wins wherever its scope applies. Give it a narrow scope
(a net, class or object kind), or reorder priorities in Altium's PCB
Rules and Constraints Editor afterwards. get_pcb_rules lists all rules
with their priorities. Check the result's "descriptor": it is what
Altium stored.
Args:
rule_type (str): One of the kinds above.
name (str): Rule name, unique on the board.
values (dict): The values for that kind, e.g. {"gap_mils": 8}.
scope1 (str): First (or only) object scope.
scope2 (str): Second scope, for two-object rules such as clearance.
comment (str): Optional rule comment.
replace (bool): Replace an existing rule of the same name instead
of refusing.
board_path (str): Full path of the .PcbDoc; empty for the focused
board, or the one the PCB tools last used.
Returns:
str: JSON with the rule's name, descriptor, scopes, priority and
whether it replaced an existing rule.get_output_job_containers tool
Get all available output job containers from a specified OutJob file
Args:
outjob_path (str): Full path to the OutJob file (optional). When empty,
the first OutJob found in the open projects is used, in project
order, regardless of which document has focus.
Returns:
str: JSON with outjob_path (the file actually used) and the containersget_outjob_settings tool
Read an .OutJob file from disk and return its outputs, containers and settings.
Works without Altium and on OutJobs that are not open. It reads the SAVED
file: changes not yet saved in Altium are not visible.
Notes for interpreting the result:
- An output is generated when it is connected to a container
(connected_containers non-empty). The per-output "enabled" flag mirrors
OutputEnabledN in the file and does not always match the UI.
- Gerber layers are decoded from Altium V7 layer IDs; unknown IDs are
reported as "Unknown layer 0x...".
Args:
outjob_path (str): Full path to the .OutJob file
include_raw_settings (bool): Also return raw_settings, the output's
settings as the file has them, for outputs with a decoded
summary. It doubles the reply. Outputs without a summary always
have raw_settings.
Returns:
str: JSON with path, group_name, variant, containers (name, type,
output paths, file name expression, add_to_project) and outputs
(type, name, document_path, variant, connected_containers and a
decoded summary for Gerber, NC Drill, test points, pick and
place and print outputs, or sections by name for a BOM)create_outjob tool
Create a new .OutJob file, empty or as a copy of another OutJob.
An output's settings are long and board specific, so the usual way to
get outputs is a template: one of your existing OutJobs (CAM, documents,
...). Then shape it with edit_outjob. An OutJob runs only from a
project: give project_path to add it to one (the project is opened in
Altium and saved; refused when it has unsaved changes there).
Args:
outjob_path (str): Full path of the new .OutJob; must not exist yet.
template_path (str): OutJob to copy; empty for an OutJob with only
the Print Job container.
project_path (str): .PrjPcb to add the new OutJob to.
Returns:
str: JSON with the containers and outputs of the new OutJob, and the
project it was added to.edit_outjob tool
Change an .OutJob: its containers, which outputs it has and where they go.
Operations run in order. One that fails is reported in "errors" and
the rest still run, but then nothing is written: the file changes only
when every operation succeeded. The file is edited in place, keeping
everything not changed as Altium wrote it. If the OutJob is open in
Altium it is closed first and opened again after, also when the write
fails (refused when it has unsaved changes there). Altium is not started
when it is not running.
Operations, each a dict with "op":
add_container name, type ("generated_files" or "pdf"), [folder]
(relative to the project, e.g. "Fab"),
[file_name] (pdf), [open_outputs] (default false:
the files are not opened after each run). Other
settings are copied from a container of the same
type, but not its folder or file name; a second PDF
container needs a folder or file_name.
set_container name, [new_name], [folder], [file_name], [open_outputs]
remove_container name
copy_output output (name or number), [from_outjob] (another
.OutJob; this one if left out), [new_name],
[containers] (names to put it in)
remove_output output
set_output output, [new_name], [enabled], [document_path],
[containers] ({container name: true/false}, or
a list of names to put it in)
set_output_setting output, key, value: one setting inside the output's
configuration, e.g. key "GerberUnit" value "Metric".
The key must already be there; get_outjob_settings
with include_raw_settings shows them.
Run with run_output_jobs; check with get_outjob_settings.
Args:
outjob_path (str): Full path of the .OutJob.
operations (list): The operations, as above.
dry_run (bool): Report what would change without writing.
Returns:
str: JSON with what was done, errors, and the containers and outputs
after the edit.list_open_documents tool
List the documents open in Altium.
Returns:
str: JSON with documents [{path, kind, modified, active}]: kind as
Altium names it (PCB, SCH, PCBLIB, ...), modified when it has
unsaved changes, active for the one in frontreload_document tool
Close an open document and open it again from disk, e.g. after the file
was replaced or edited outside Altium. Altium saves its own copy over the
file otherwise, so never change a file on disk while it is open without
reloading it here.
Args:
path (str): Full path of the open document
discard_changes (bool): Reload even when the document has unsaved
changes, dropping them. Default false: such a document is refused.
Returns:
str: JSON with path, kind, and the file's size (file_size) and
modification time (file_mtime, ISO 8601) as it was loadedget_project_info tool
Get the focused Altium project: parameters, documents and variants.
Read-only. Use it to check that nothing has unsaved changes before
generating outputs, and to read project parameters and variants.
Returns:
str: JSON with project_path, parameters [{name, value}],
schematic_sheet_count, modified_document_count, documents
[{path, kind, state}] where state is "closed", "open" or
"modified" (unsaved changes in memory), and variants
[{name, variations [{designator, kind}]}] where kind is
"not_fitted" or "alternate"get_project_components tool
List the components of the compiled project (schematic side).
Compiles the project in memory first (nothing is saved): project_path,
or the focused project, as for get_erc_violations. Unlike
the PCB component tools, this returns the schematic Comment of each
instance, which is where values of generic passives usually live.
A large project does not fit in one reply. A reply stops at about 60,000
characters: when next_offset is not null, call again with
offset=next_offset and the same filters for the rest. Filter first when
you can: all parameters of every part can come to megabytes.
Args:
include_parameters (bool): Also return every component parameter
(e.g. Manufacturer_Part_Number). Default False - the output is
much larger with parameters.
designators (list): Only these designators. Wildcards work and case
does not matter, e.g. ["R*", "U1", "C1?"].
sheet (str): Only this sheet, by file name ("Power.SchDoc");
wildcards work.
offset (int): Skip this many matching components.
limit (int): At most this many components; 0 for as many as fit.
parameter_names (list): Return only these parameters, e.g.
["Manufacturer_Part_Number"]. Implies include_parameters.
project_path (str): Full path of the .PrjPcb to compile.
Returns:
str: JSON with project_path, component_count (the whole project),
matched, offset, returned, next_offset and components
[{designator, comment, footprint, library_reference, sheet,
parameters?}]get_erc_violations tool
Compile a project and list its ERC/compiler violations.
Give project_path to compile exactly that project (it is opened if
needed): without it the focused project is compiled, which is whatever
document last had focus, and "Free Documents" is refused. The result
names the project it compiled.
Compiling reads each sheet from disk, except a sheet open in Altium with
unsaved changes: that one is compiled from Altium's copy and listed in
unsaved_in_altium. Save it (or close it unsaved) for the file to count.
Sheets the project lists but that are not on disk are in
missing_on_disk. Compiling does not save any document (Altium may
refresh the derived .PrjPcbStructure file).
Args:
compile (bool): Compile before reading (default True). False returns
the violations of the last compilation.
project_path (str): Full path of the .PrjPcb to compile.
Returns:
str: JSON with project_path, unsaved_in_altium, missing_on_disk,
total, fatal, errors, warnings and violations
[{level, type, detail}]compare_netlist tool
Compile the project and compare its netlist with a saved one: the
safety net for editing sheets in place. Call it before an edit (the
first call only saves) and again after: it lists the nets that gained or
lost pins, the pins that moved between nets, nets added, removed or
renamed, and nets left with a single pin.
Snapshots are kept per project (by its full path, so a copy of a
project in another folder keeps its own) under a name. By default each
call compares with the previous call ("last") and then saves itself as
"last". Save a fixed baseline with save_as="before" and compare later
calls with against="before". The 20 most recently saved snapshots of a
project are kept; saving another removes the oldest (listed in
"pruned"). A snapshot that cannot be read as one is an error.
An auto-named net (NetR1_1) whose pins stay together under a new name is
a rename, not a removal and an addition. That matching is greedy: each
vanished net takes the new net it shares most pins with, in turn, so
when two vanished nets overlap the same new net only the first is a
rename. Compiling reads the sheets as they are open in Altium, unsaved
edits included.
Args:
project_path (str): Full path of the .PrjPcb; empty for the focused
project.
against (str): The snapshot to compare with; "" to only save.
save_as (str): Save this netlist under that name; "" to not save.
max_per_kind (int): At most this many entries per list.
Returns:
str: JSON with summary (count per kind of change), the changes, the
snapshot compared with (and when it was saved), the
unsaved sheets, and the snapshots pruned to make room.preview_eco tool
Show what Design > Update PCB would change, without running it: the
differences between the compiled schematics and the board, as data.
Run it before an Update PCB, in particular to catch rooms and classes the
ECO would remove (a room drawn for a class the schematics no longer make
disappears with the update), footprint changes and net renames.
Compiles the project in memory (nothing is saved) and reads the board
without bringing it to the front. Components match by unique id, nets by
their pins (a net whose pins stay together under a new name is a
rename), rooms and classes by name. The project's options, as saved in
the .PrjPcb, are followed: kinds the comparator ignores (Project Options
> Comparator) or the ECO does not generate (ECO Generation), and classes
and rooms the project does not generate (Class Generation), are left
out and counted in skipped_by_project_options. Duplicate component
class names (Altium's "Class already exists" warning, usually from a
sheet symbol that lists several files) are explained in
duplicate_component_classes. As Altium's ECO does, with "Netlist single
pin nets" off a pin alone on an auto-named net (NetR1_1) counts as on no
net (it is not connected, and leaves a board net it is on), while a
named one-pin net is made with its pin (Altium lists that as Add Nets
only); board parts with no schematic link are left alone and listed in
board_only_components, outside the summary.
Not compared, so an empty summary means "no differences of the kinds
compared", not that an Update PCB would change nothing: net class
members (net classes match by name only), component parameters,
differential pairs, rules from parameter sets, and room scope and
members (rooms match by name only).
Args:
project_path (str): Full path of the .PrjPcb; default the focused project.
pcb_path (str): The board to compare; default the project's PCB.
max_per_kind (int): At most this many entries per kind (default 50);
"summary" always has the full counts.
Returns:
str: JSON with project_path, pcb_path, unsaved_in_altium (sheets
compiled from unsaved edits), summary {kind: count}, and per kind:
add_components, remove_components, change_designators,
change_footprints, change_comments, add_nets, remove_nets,
rename_nets, change_pin_nets, add/remove_component_classes,
change_component_class_members, add/remove_net_classes,
add_rooms, remove_rooms, duplicate_component_classes,
board_only_components, skipped_by_project_options ({kind,
count, reason}); project_options_note if the .PrjPcb could not
be read (then nothing is left out)get_board_summary tool
Summarise the focused PCB for fabrication checks.
Read-only. Coordinates are millimetres relative to the board origin.
Returns:
str: JSON with pcb_path, board origin (absolute), board_outline
(bounding box, width, height, vertex count), dimensions (cotas)
with their extents, via_count and vias_by_hole, components per
side, layer_contents (primitive count per layer, split into free
objects and objects inside components) and overlay_texts (free
texts on Top/Bottom Overlay, e.g. board name and revision)get_component_primitives tool
List the primitives of PCB components with the layer each one is on.
Read-only. Useful to check footprints that were flipped to the bottom
side (e.g. fiducials: the copper and the pad that opens the solder mask
must end up on the same layer) and pad mask expansions.
Args:
designators (list): Component designators, e.g. ["FD1", "FD3"]
Returns:
str: JSON with components [{designator, footprint, layer, x_mm, y_mm,
rotation, primitives [{type, layer, ...}]}] and
missing_designatorsrun_output_jobs tool
Run specified output job containers
The OutJob's project must be open in Altium. A PDF (Publish) container
reports output_file and output_verified: true once Altium has written
that file. output_verified is false for generated-file containers and
for PDFs that Altium names itself (after each output, or from an
expression). When a PDF already exists and the container prompts before
overwriting (the default), Altium asks in a dialog and the run waits for
the answer.
Args:
container_names (list): List of container names to run
outjob_path (str): Full path to the OutJob file (optional). When empty,
the first OutJob found in the open projects is used, in project
order, regardless of which document has focus.
Returns:
str: JSON object with outjob_path (the file actually used) and the
results of running the output jobscreate_pcb_footprint tool
Create a new PCB footprint in the currently active PcbLib document.
The PcbLib (e.g. Discrete.PcbLib) must be the focused document in Altium.
Pad format: each element is "pad_number|x_mm|y_mm|width_mm|height_mm|shape"
shape options: Rect (default), Round, Oval
Coordinates are in mm relative to component origin (0,0).
Pin 1 is indicated by a gap in the top-left silkscreen corner.
Pads are created locked.
Courtyard & silkscreen are auto-generated from pad extents + 0.25 mm margin
unless courtyard_x_mm / courtyard_y_mm are provided explicitly (half-dimensions).
The gap is always at the top-left corner of the outline, wherever pad 1
is, and the courtyard is always on Mechanical 15. For other conventions
use create_footprints_batch, which takes layers by name and any tracks.
Args:
footprint_name (str): Footprint name as it will appear in the library
description (str): Description string
pads (list): List of pad definitions, e.g. ["1|-0.9|0.55|1.0|0.8|Rect", ...]
courtyard_x_mm (float): Half-width of courtyard in mm (0 = auto)
courtyard_y_mm (float): Half-height of courtyard in mm (0 = auto)
Returns:
str: JSON object with resultget_server_status tool
Get the current status of the Altium MCP server
What we checked
The same checks run on every server. Each line below has one of these marks:
- 8 checks: command injection, argument injection, path traversal, server-side request forgery, SQL injection, code execution, unsafe deserialization, template injectionChecked on every scan. Results in this category are published only after a person has verified them.
- Runs programs the caller choosesNo tool runs a command or program the caller supplies — 89 tool handlers traced. Not every path could be followed, so this is not a clean pass.
- Executes caller-supplied codeNo tool evaluates code the caller supplies — 89 tool handlers traced. Not every path could be followed, so this is not a clean pass.
- Reads or writes any file path4 findings the scanner could not decide; see the findings below
- Requests any addressNo tool sends a request to an address the caller supplies — 89 tool handlers traced. Not every path could be followed, so this is not a clean pass.
- Runs caller-supplied SQLNo tool executes a query the caller supplies — 89 tool handlers traced. Not every path could be followed, so this is not a clean pass.
- Tools that start processes4 of 90 capabilities start processes; 85 more call code the scanner could not follow, where it may happen
- Tools that touch files84 of 90 capabilities touch files; 5 more call code the scanner could not follow, where it may happen
- Tools that call the networkNot seen in the traced code of 90 capabilities; 89 more call code the scanner could not follow, where it may happen
Where the code is: 90 handlers in 1 file at commit c0f86dabd0ff
server/main.py(name computed at run time), get_all_component_property_names, get_component_property_values, get_symbol_placement_rules, get_library_symbol_reference, search_library_symbol, create_schematic_symbol, get_schematic_data, get_pcb_layers, set_pcb_layer_visibility, get_component_data, get_selected_components_coordinates +78
- 5 checks: tool poisoning, instruction override, hidden content, exfiltration requests, metadata integrityChecked on every scan. Results in this category are published only after a person has verified them.
- Dependency manifests2 manifests: pyproject.toml, requirements.txt
- Lockfiles checked against OSV2 files resolved and checked against the OSV database; 1 not resolved: pyproject.toml: dependency ranges declared here were not resolved against a lockfile and were not checked
- Known vulnerabilities in production dependencies CRITICAL8 production packages with known advisories
- Known vulnerabilities in other dependenciesNo package used only for development, tests or examples has a known advisory
- MCP SDK versionmcp ==1.30.0
- 3 checks: credential harvesting, undeclared credential access, credentials sent over the networkChecked on every scan. Results in this category are published only after a person has verified them.
- Tools that read credentialsNot seen in the traced code of 90 capabilities; 89 more call code the scanner could not follow, where it may happen
- Environment variables2 capabilities read environment variables (often API keys)
- Authentication declaredNot checked: needs the live server's tools/list (a remote server declares how clients authenticate)
- 3 checks: undeclared network access, undeclared file access, undeclared process executionChecked on every scan. Results in this category are published only after a person has verified them.
- Tool descriptions presentEvery tool has a description the model and the user can read
- Statically known namesEvery tool's name could be read from the code
- Input schemasNot checked: needs the live server's tools/list (every tool declares an input schema)
- Destructive tools annotatedNot checked: needs the live server's tools/list (tools that write, delete or run commands carry destructivehint)
Dependencies with known vulnerabilities (8 in production)
Dependency ranges were not resolved against a lockfile, so the score is capped at 7.
pillowPyPI 11.1.0 CRITICAL 90 advisories 12.1.112.2.012.3.0+1 more
- CRITICALGHSA-332p-7hrc-92wf BIT-pillow-2026-112393 CVE-2026-112393Pillow: Heap buffer overflow in _tiffWriteProc when saving TIFF to BytesIO
- CRITICALGHSA-8g5g-8vmr-9782 BIT-pillow-2026-112403 CVE-2026-112403 PYSEC-2026-4332Pillow: Heap buffer overflow in ImagingJpegDecode
- CRITICALGHSA-w889-685w-c8fh BIT-pillow-2026-112900 CVE-2026-112900Pillow: Argument Injection in Ghostscript call, potentially leading into RCE
- CRITICALGHSA-v9pv-5gc8-w2m6 BIT-pillow-2026-96639 CVE-2026-96639 PYSEC-2026-4339Pillow multi-frame loaders can reuse stale native image storage after mode transitions
- CRITICALGHSA-5x8w-8jj5-q52h BIT-pillow-2026-112398 CVE-2026-112398 PYSEC-2026-4330Pillow: Heap buffer overflow in FlashPix (FPX) JPEG decoding leads to code execution
- HIGHGHSA-vjc4-5qp5-m44j BIT-pillow-2026-59204 CVE-2026-59204 PYSEC-2026-3496Pillow JPEG2000 tiled decode retains a growing scratch buffer and can be used for denial of service
- HIGHGHSA-22hg-r758-rrw9 BIT-pillow-2026-112390 CVE-2026-112390Pillow: Infinite loop in MIC n_frames when the embedded TIFF
- HIGHGHSA-j4m9-6w36-pw47 BIT-pillow-2026-112893 CVE-2026-112893Pillow: Invalid free in FreeType glyph rendering when a stroker is active
- HIGHGHSA-xcvg-w56q-r89m CVE-2026-128067Pillow: Heap buffer overflow saving TIFF with libtiff when tags override image size
- HIGHGHSA-f2g6-542v-9j58 BIT-pillow-2026-112406 CVE-2026-112406Pillow: Infinite loop in PdfParser.rewrite_pages on page tree Parent cycle
- HIGHGHSA-jjj6-mw9f-p565 BIT-pillow-2026-59200 CVE-2026-59200 PYSEC-2026-3495Pillow: Decompression Bomb DoS via PdfParser.PdfStream.decode()
- HIGHGHSA-g842-9rc4-69pw BIT-pillow-2026-96637 CVE-2026-96637 PYSEC-2026-4338Pillow: Decompression bomb check bypass in SpiderImagePlugin.seek() leads to unbounded allocation DoS
- HIGHGHSA-5xm2-6676-qcp9 BIT-pillow-2026-112399 CVE-2026-112399Pillow: APNG background disposal allocates full canvas before decompression bomb check
- HIGHGHSA-7mwm-ghpf-9vrm BIT-pillow-2026-112402 CVE-2026-112402 PYSEC-2026-4331Pillow: Double free in ImagingScaleAffine on calloc failure via Image.transform
- HIGHGHSA-pwv6-vv43-88gr BIT-pillow-2026-42311 CVE-2026-42311 PYSEC-2026-2252Pillow has an OOB Write with Invalid PSD Tile Extents (Integer Overflow)
- HIGHGHSA-g4qv-2jxx-769h BIT-pillow-2026-96643 CVE-2026-96643 PYSEC-2026-4342Pillow: PNG eXIf chunk makes EXIF parsing run in quadratic time
- HIGHGHSA-65qm-jvmh-6pqg BIT-pillow-2026-112400 CVE-2026-112400Pillow: GIF seek keeps rejected size after DecompressionBombError, allowing DoS
- HIGHGHSA-mrfp-p49p-3hf2 BIT-pillow-2026-96640 CVE-2026-96640Pillow PDF append accepts malformed shared page-tree DAG causing resource exhaustion
- HIGHGHSA-phj9-mv4w-65pm BIT-pillow-2026-55380 CVE-2026-55380 PYSEC-2026-2256Pillow `GdImageFile._open()`: image dimensions accepted without `_decompression_bomb_check()`
- HIGHGHSA-c6hw-5grf-ff96 BIT-pillow-2026-112404 CVE-2026-112404Pillow: OOB read in TiffDecode.c tile and RGBA paths leaks heap memory into pixels
- HIGHGHSA-9v9v-9qvf-h2hj BIT-pillow-2026-96644 CVE-2026-96644 PYSEC-2026-4343Pillow: Heap over-read in WMF/EMF rendering via 16-bit dimension truncation (Windows builds)
- HIGHGHSA-cfh3-3jmp-rvhc BIT-pillow-2026-25990 CVE-2026-25990 PYSEC-2026-2249Pillow affected by out-of-bounds write when loading PSD images
- HIGHGHSA-jg86-v3jv-hrpm BIT-pillow-2026-112894 CVE-2026-112894Pillow: Quadratic-time DoS in PDF save_all (PdfParser.next_object_id)
- HIGHGHSA-62p4-gmf7-7g93 BIT-pillow-2026-54058 CVE-2026-54058 PYSEC-2026-3493Pillow: Out-of-bounds read via attacker-controlled row stride on Pillow's mmap path (McIdas AREA files)
- HIGHGHSA-9hw9-ch79-4vh6 BIT-pillow-2026-59205 CVE-2026-59205 PYSEC-2026-3453Pillow: Controlled heap out-of-bounds write in Pillow `ImageCmsTransform.apply()` via output mode mismatch
- HIGHGHSA-g7cr-3p24-7wf7 BIT-pillow-2026-96778 CVE-2026-96778Pillow: Heap buffer overflow writing JPEG comment after ICC profile fills buffer
- HIGHGHSA-xj96-63gp-2gmr BIT-pillow-2026-59197 CVE-2026-59197 PYSEC-2026-3454Pillow: Heap out-of-bounds write in `ImageFilter.RankFilter` via integer overflow in `ImagingExpand`
- HIGHGHSA-27h8-gf7j-v5hc BIT-pillow-2026-112392 CVE-2026-112392 PYSEC-2026-4326Pillow: NULL dereference in ImagingExpand via rank filters on zero-size images
- HIGHGHSA-xvh5-g6gv-559v BIT-pillow-2026-112902 CVE-2026-112902 PYSEC-2026-4363 Pillow: Memory disclosure and segfault in libtiff encoder via crafted TIFF tags
- HIGHGHSA-whj4-6x5x-4v2j BIT-pillow-2026-40192 CVE-2026-40192 PYSEC-2026-2250FITS GZIP decompression bomb in Pillow
- HIGHGHSA-p4wg-p73j-c528 BIT-pillow-2026-112895 CVE-2026-112895Pillow: Unbounded recursion parsing a PDF page tree or trailer chain (incomplete fix for CVE-2026-42310)
- HIGHGHSA-pchr-8j38-3x4p BIT-pillow-2026-112896 CVE-2026-112896 PYSEC-2026-4334Pillow: TIFF encoder ColorMap plane-size mismatch causes a heap out-of-bounds read
- HIGHGHSA-q45j-58j2-45rg BIT-pillow-2026-112897 CVE-2026-112897Pillow: TiffDecode returns uninitialized memory as pixels for short JPEG strips
- HIGHGHSA-5x94-69rx-g8h2 BIT-pillow-2026-54060 CVE-2026-54060 PYSEC-2026-2254Pillow: `FontFile.compile()`: `Image.new()` called without `_decompression_bomb_check()`
- HIGHGHSA-6r8x-57c9-28j4 BIT-pillow-2026-59199 CVE-2026-59199 PYSEC-2026-3451Pillow: Heap out-of-bounds write `Image.paste()` / `Image.crop()` via signed coordinate overflow
- HIGHGHSA-3j72-p6qg-6xp7 BIT-pillow-2026-96642 CVE-2026-96642 PYSEC-2026-4341Pillow: TarIO negative size field causes infinite CPU-spin loop
- HIGHGHSA-78g4-xqwv-q3g8Pillow: Bundled libopenjp2 2.5.4 in all wheels since 11.1.0 carries OSV-2025-219 heap-buffer-overflow write reachable from Image.open().load()
- HIGHGHSA-8v84-f9pq-wr9x BIT-pillow-2026-54059 CVE-2026-54059 PYSEC-2026-2253Pillow `PcfFontFile._load_bitmaps()`: `Image.frombytes()` called without `_decompression_bomb_check()` — bomb protection bypass via PCF font loading
- HIGHGHSA-45hq-cxwh-f6vc BIT-pillow-2026-55379 CVE-2026-55379 PYSEC-2026-2255Pillow `BdfFontFile`: `Image.new()` called without `_decompression_bomb_check()` — bomb protection bypass via font loading
- HIGHGHSA-58r4-6rv3-gfh8 BIT-pillow-2026-112397 CVE-2026-112397 PYSEC-2026-4329Pillow: Out-of-bounds access in _imagingmorph on a zero-width image
- HIGHGHSA-gg2r-wvfm-q9rx BIT-pillow-2026-112892 CVE-2026-112892Pillow: MSP RLE decoder expands a tiny file into unbounded memory
- MEDIUMPYSEC-2026-2254 BIT-pillow-2026-54060 CVE-2026-54060 GHSA-5x94-69rx-g8h2Pillow is a Python imaging library. Prior to 12.3.0, PIL/FontFile.py FontFile.compile() assembled per-glyph images into a combined bitmap with Image.new("1", (xsize, ysize)) without calling Image._decompression_bomb_check(), allowing a font to trigger excessive allocation during conversion or saving. This issue is fixed in version 12.3.0.
- MEDIUMGHSA-4x4j-2g7c-83w6 BIT-pillow-2026-55798 CVE-2026-55798 PYSEC-2026-2257Pillow: WindowsViewer.get_command() OS command injection via unescaped shell path
- MEDIUMGHSA-74r2-7ff9-mjj2 BIT-pillow-2026-112401 CVE-2026-112401Pillow: Quadratic GIF comment concatenation allows DoS in Image.open()
- MEDIUMPYSEC-2026-4341 BIT-pillow-2026-96642 CVE-2026-96642 GHSA-3j72-p6qg-6xp7Pillow is a Python imaging library. Prior to 13.0.0, the TarIO initializer in src/PIL/TarIO.py accepts a negative octal member size and computes a backward seek that returns to the same 512-byte header. When the requested member name does not match, the parser repeatedly reads that header, consumes a full CPU core, and never returns. TarIO is reached only when an application directly uses PIL.TarIO.TarIO rather than the default Image.open() path. This issue is fixed in version 13.0.0.
- MEDIUMPYSEC-2026-4330 BIT-pillow-2026-112398 CVE-2026-112398 GHSA-5x8w-8jj5-q52hPillow is a Python imaging library. Prior to 13.0.0, Pillow's FlashPix JPEG-tile decoder can write decoded scanlines beyond the allocated tile buffer. FlashPix (FPX) JPEG decoding selects raw mode LA with two bytes per pixel, while an unrecognized JPEG mode can be decoded as JCS_UNKNOWN with four components, causing ImagingJpegDecode to write four-component scanlines into the two-byte tile buffer. An attacker can supply a crafted OLE2 FlashPix file to an application with the optional olefile dependency installed that opens or thumbnails untrusted input. This can corrupt heap memory and may allow arbitrary code execution. This issue is fixed in version 13.0.0.
- MEDIUMPYSEC-2026-4338 BIT-pillow-2026-96637 CVE-2026-96637 GHSA-g842-9rc4-69pwPillow is a Python imaging library. Prior to 13.0.0, SpiderImageFile.seek() in src/PIL/SpiderImagePlugin.py reparses a later SPIDER stack frame and replaces self._size without rerunning Image._decompression_bomb_check(). A tiny file can use a safe first frame to pass Image.open() and then declare very large dimensions in a later mode F frame. Loading that frame allocates approximately four bytes per attacker-declared pixel and can consume multiple gigabytes of memory. This issue is fixed in version 13.0.0.
- MEDIUMGHSA-254f-3936-288h BIT-pillow-2026-112391 CVE-2026-112391Pillow: PdfParser can recurse without limit in get_value() and linearize_page_tree()
- MEDIUMPYSEC-2026-3451 BIT-pillow-2026-59199 CVE-2026-59199 GHSA-6r8x-57c9-28j4Pillow is a Python imaging library. Prior to 12.3.0, Pillow public image coordinate APIs can trigger a native heap out-of-bounds write when given coordinates near the signed 32-bit integer limits in Image.paste(), Image.crop(), or Image.alpha_composite(). This issue is fixed in version 12.3.0.
- MEDIUMPYSEC-2026-3494 BIT-pillow-2026-59198 CVE-2026-59198 GHSA-fj7v-r99m-22gqPillow TGA RLE encoder can serialize up to ~57 KB of adjacent heap data into generated images
- MEDIUMPYSEC-2026-2250 BIT-pillow-2026-40192 CVE-2026-40192 GHSA-whj4-6x5x-4v2jPillow is a Python imaging library. Versions 10.3.0 through 12.1.1 did not limit the amount of GZIP-compressed data read when decoding a FITS image, making them vulnerable to decompression bomb attacks. A specially crafted FITS file could cause unbounded memory consumption, leading to denial of service (OOM crash or severe performance degradation). If users are unable to immediately upgrade, they should only open specific image formats, excluding FITS, as a workaround.
- MEDIUMPYSEC-2026-165 BIT-pillow-2026-42308 CVE-2026-42308 GHSA-wjx4-4jcj-g98jPillow is a Python imaging library. Prior to version 12.2.0, if a font advances for each glyph by an exceeding large amount, when Pillow keeps track of the current position, it may lead to an integer overflow. This issue has been patched in version 12.2.0.
- MEDIUMPYSEC-2026-2256 BIT-pillow-2026-55380 CVE-2026-55380 GHSA-phj9-mv4w-65pmPillow is a Python imaging library. Prior to 12.3.0, PIL/GdImageFile.py GdImageFile._open() read image dimensions from the GD 2.x header and stored them in self._size without calling Image._decompression_bomb_check(), allowing a crafted .gd file to trigger excessive C-heap allocation when loaded. This issue is fixed in version 12.3.0.
- MEDIUMPYSEC-2026-3454 BIT-pillow-2026-59197 CVE-2026-59197 GHSA-xj96-63gp-2gmrPillow is a Python imaging library. Prior to 12.3.0, Pillow's public rank-filter API can trigger a native heap out-of-bounds write when given a very large odd filter size because ImageFilter.RankFilter.filter() calls image.expand(size // 2, size // 2) before rank-filter size validation and ImagingExpand() computes output dimensions with unchecked signed int arithmetic. This issue is fixed in version 12.3.0.
- MEDIUMGHSA-4558-3h8r-v8xp BIT-pillow-2026-112394 CVE-2026-112394 PYSEC-2026-4327Pillow: P;2L and P;4L decoders may read 1 to 3 bytes past the passed buffer size
- MEDIUMPYSEC-2026-2249 BIT-pillow-2026-25990 CVE-2026-25990 GHSA-cfh3-3jmp-rvhcPillow is a Python imaging library. From 10.3.0 to before 12.1.1, an out-of-bounds write may be triggered when loading a specially crafted PSD image. This vulnerability is fixed in 12.1.1.
- MEDIUMPYSEC-2026-4331 BIT-pillow-2026-112402 CVE-2026-112402 GHSA-7mwm-ghpf-9vrmPillow is a Python imaging library. Prior to 13.0.0, Pillow can double free image memory when ImagingScaleAffine encounters a selective allocation failure. The affected fast path handles Transform.EXTENT or pure scale-and-translate Transform.AFFINE operations with the default NEAREST resampling. The output image allocation must succeed while the additional per-column lookup allocation fails, after which the error path deletes image storage that later cleanup releases again. An attacker who can drive such a large Image.transform() operation under memory pressure may trigger the failure. This can crash the process and may corrupt memory. This issue is fixed in version 13.0.0.
- MEDIUMGHSA-wqgw-9xfh-qf2g CVE-2026-128066Pillow: Memory DoS in TIFF and EXIF IFD parsing via overlapping tag data
- MEDIUMPYSEC-2026-4326 BIT-pillow-2026-112392 CVE-2026-112392 GHSA-27h8-gf7j-v5hcPillow is a Python imaging library. Prior to 13.0.0, Pillow's rank-based filters can dereference invalid image storage for a zero-size image. ImagingExpand() allocates a non-empty output and then faults while replicating edges by reading the first pixel from empty input storage; ImagingRankFilter is never reached. An attacker can supply or cause creation of a zero-size image to an application that applies a rank, median, minimum, or maximum filter. This causes a native process crash. This issue is fixed in version 13.0.0.
- MEDIUMGHSA-4rm8-3hmm-39fg BIT-pillow-2026-96641 CVE-2026-96641 PYSEC-2026-4340Pillow: Reachable undefined behavior in native integer operations, potentially leading to denial of service or logic integrity compromise
- MEDIUMPYSEC-2026-4342 BIT-pillow-2026-96643 CVE-2026-96643 GHSA-g4qv-2jxx-769hPillow is a Python imaging library. From 11.0.0 until 13.0.0, Exif.load() in src/PIL/Image.py repeatedly slices the remaining EXIF data while it begins with the six-byte Exif header. src/PIL/PngImagePlugin.py accepts an uncapped PNG eXIf chunk, so a file filled with repeated headers causes a new shrinking copy on every iteration and quadratic CPU work. The condition is reachable through Image.getexif(), Image._getexif(), and ImageOps.exif_transpose(), including common photo-upload rotation workflows. This issue is fixed in version 13.0.0.
- MEDIUMGHSA-462x-pgg6-55fp BIT-pillow-2026-112395 CVE-2026-112395Pillow tiled-TIFF decoder reads past tile buffer in copy4 (Unpack.c:1290)
- MEDIUMPYSEC-2026-4340 BIT-pillow-2026-96641 CVE-2026-96641 GHSA-4rm8-3hmm-39fgPillow is a Python imaging library. Prior to 13.0.0, PILfont text-width accumulation in src/_imaging.c checks positive glyph advances against INT_MAX but does not check negative advances against INT_MIN. Repeating a signed 16-bit advance of -32768 can therefore execute a signed C integer overflow in xsize += dx, producing a large positive width from a negative mathematical result. Applications that use getlength(), getsize(), or derived layout, quota, serialization, or allocation calculations can experience logic-integrity errors or resource consumption, while the high-level mask path commonly retains a decompression-bomb check. This issue is fixed in version 13.0.0.
- MEDIUMPYSEC-2026-4327 BIT-pillow-2026-112394 CVE-2026-112394 GHSA-4558-3h8r-v8xpPillow is a Python imaging library. Prior to 13.0.0, Pillow's P;2L and P;4L raw decoders can read past the end of an input buffer. ImagingRawDecode calculates a packed-pixel row size, while the unpackers read separately padded bit planes. A caller can supply a buffer and image dimensions whose accepted size is smaller than the unpacker's actual footprint. This can disclose up to three adjacent heap bytes in output pixels or crash the process. This issue is fixed in version 13.0.0.
- MEDIUMPYSEC-2026-2252 BIT-pillow-2026-42311 CVE-2026-42311 GHSA-pwv6-vv43-88grPillow is a Python imaging library. From version 10.3.0 to before version 12.2.0, processing a malicious PSD file could lead to memory corruption, potentially resulting in a crash or arbitrary code execution. This issue has been patched in version 12.2.0.
- MEDIUMPYSEC-2026-3493 BIT-pillow-2026-54058 CVE-2026-54058 GHSA-62p4-gmf7-7g93Pillow: Out-of-bounds read via attacker-controlled row stride on Pillow's mmap path (McIdas AREA files)
- MEDIUMPYSEC-2026-2255 BIT-pillow-2026-55379 CVE-2026-55379 GHSA-45hq-cxwh-f6vcPillow is a Python imaging library. Prior to 12.3.0, PIL/BdfFontFile.py bdf_char() read the BBX width and height field from a BDF font file and passed attacker-controlled dimensions to Image.new() without calling Image._decompression_bomb_check(), bypassing Pillow's documented decompression bomb protection and allowing excessive memory allocation. This issue is fixed in version 12.3.0.
- MEDIUMPYSEC-2026-3453 BIT-pillow-2026-59205 CVE-2026-59205 GHSA-9hw9-ch79-4vh6Pillow is a Python imaging library. Prior to 12.3.0, Pillow's ImageCms.ImageCmsTransform.apply(im, imOut) API can trigger controlled native heap corruption when the caller supplies an output image whose mode does not match the transform's declared output mode. This issue is fixed in version 12.3.0.
- MEDIUMPYSEC-2026-4329 BIT-pillow-2026-112397 CVE-2026-112397 GHSA-58r4-6rv3-gfh8Pillow is a Python imaging library. Prior to 13.0.0, Pillow's ImageMorph.MorphOp.apply() can access memory before a row buffer for a zero-width image. PPM and PGM input can create an image with width zero, and the native morphology routine indexes outrow[width - 1] without rejecting that geometry. An attacker can supply such an image to an application that applies a morphology operation. This can crash the process. This issue is fixed in version 13.0.0.
- MEDIUMGHSA-wjx4-4jcj-g98j BIT-pillow-2026-42308 CVE-2026-42308 PYSEC-2026-165Pillow has an integer overflow when processing fonts
- MEDIUMGHSA-p8hx-v2p6-rp84 BIT-pillow-2026-96636 CVE-2026-96636 PYSEC-2026-4337Pillow: Decompression-bomb protection bypass via multi-frame seek() in MPO and DCX (MpoImageFile.seek / DcxImageFile.seek)
- MEDIUMGHSA-rfgq-q3w2-pmv2 BIT-pillow-2026-112898 CVE-2026-112898Pillow: Image.quantize() with empty palette leaks uninitialized stack memory
- MEDIUMPYSEC-2026-4334 BIT-pillow-2026-112896 CVE-2026-112896 GHSA-pchr-8j38-3x4pPillow is a Python imaging library. Prior to 13.0.0, Pillow's TIFF encoder can read beyond a ColorMap buffer when retained TIFF metadata has a plane size inconsistent with BitsPerSample. A small TIFF can be opened normally and then retain a crafted ColorMap that is reused when the image is saved. An application that re-encodes the attacker's TIFF with libtiff can trigger the out-of-bounds read. This can disclose heap memory in the output or crash the process. This issue is fixed in version 13.0.0.
- MEDIUMPYSEC-2026-4343 BIT-pillow-2026-96644 CVE-2026-96644 GHSA-9v9v-9qvf-h2hjPillow is a Python imaging library. Prior to 13.0.0 on Windows, src/PIL/WmfImagePlugin.py passes unchecked 32-bit WMF or EMF dimensions to the native drawwmf handler in src/display.c. The handler sizes a DIB allocation from 16-bit-truncated bcWidth and bcHeight fields but copies pixel data using the original full dimensions. A crafted wide, short metafile can pass the pixel-count decompression-bomb check and make the Windows-only renderer read beyond the heap buffer, potentially disclosing memory or crashing the process. This issue is fixed in version 13.0.0.
- MEDIUMPYSEC-2026-2874 BIT-pillow-2026-42310 CVE-2026-42310 GHSA-r73j-pqj5-w3x7Pillow has a PDF Parsing Trailer Infinite Loop (DoS)
- MEDIUMGHSA-r73j-pqj5-w3x7 BIT-pillow-2026-42310 CVE-2026-42310 PYSEC-2026-2874Pillow has a PDF Parsing Trailer Infinite Loop (DoS)
- MEDIUMGHSA-24rc-8hj2-v98c BIT-pillow-2026-96638 CVE-2026-96638Pillow: BMP RLE decoder memory-amplification DoS via unbounded delta escape / absolute mode
- MEDIUMPYSEC-2026-3496 BIT-pillow-2026-59204 CVE-2026-59204 GHSA-vjc4-5qp5-m44jPillow JPEG2000 tiled decode retains a growing scratch buffer and can be used for denial of service
- MEDIUMPYSEC-2026-4335 BIT-pillow-2026-112901 CVE-2026-112901 GHSA-xgh8-jp6q-p5x8Pillow is a Python imaging library. Prior to 13.0.0, Pillow's XBM header parser is vulnerable to regular-expression denial of service. In XbmImageFile._open, when an application calls Image.open() on a small crafted XBM file, XbmImagePlugin applies a backtracking expression to the attacker-controlled header before image dimensions are accepted, stalling a worker for minutes and denying service. This issue is fixed in version 13.0.0.
- MEDIUMGHSA-vx6w-vv9f-6gvg BIT-pillow-2026-112899 CVE-2026-112899Pillow: EPS load(scale) lets Ghostscript render past the decompression bomb limit
- MEDIUMGHSA-fc9g-5qg7-mf45 BIT-pillow-2026-112891 CVE-2026-112891Pillow: Quadratic GIF comment copying during save
- MEDIUMPYSEC-2026-3495 BIT-pillow-2026-59200 CVE-2026-59200 GHSA-jjj6-mw9f-p565Pillow: Decompression Bomb DoS via PdfParser.PdfStream.decode()
- MEDIUMGHSA-xgh8-jp6q-p5x8 BIT-pillow-2026-112901 CVE-2026-112901 PYSEC-2026-4335Pillow: ReDoS in XbmImagePlugin: 512-byte file stalls Image.open() for minutes
- MEDIUMPYSEC-2026-4339 BIT-pillow-2026-96639 CVE-2026-96639 GHSA-v9pv-5gc8-w2m6Pillow is a Python imaging library. From 11.0.0 until 13.0.0, multi-frame loaders can retain an ImagingCore allocation created for a narrow frame mode while a later frame of the same dimensions changes the logical mode and decoder tiles to wider RGB or CMYK data. ImageFile.load_prepare() reuses the stale native storage because _im is non-null without verifying that its mode and size still match. Crafted PSD, MPO, DCX, or MIC frame transitions can then write wider pixels into the narrow allocation, causing native out-of-bounds writes and crashes. The MPO path can also cause a native over-read and, in demonstrated runtime-specific profiles, command execution. This issue is fixed in version 13.0.0.
- MEDIUMPYSEC-2026-4332 BIT-pillow-2026-112403 CVE-2026-112403 GHSA-8g5g-8vmr-9782Pillow is a Python imaging library. Prior to 13.0.0, Pillow's JPEG decoder can write a full-width scanline into a buffer sized for a requested draft scale. ImagingJpegDecode does not verify libjpeg's actual output width and component count after scaling is requested, and an 8-bit lossless SOF3 JPEG decoded by a build linked to libjpeg-turbo 3.x can ignore the requested downscaling geometry. An attacker can supply such a JPEG to an application that uses draft() or thumbnail() to request downscaling. This can corrupt heap memory, crash the process, or potentially allow code execution. Older libjpeg-turbo 2.x and IJG builds reject the SOF3 input. This issue is fixed in version 13.0.0.
- MEDIUMPYSEC-2026-2253 BIT-pillow-2026-54059 CVE-2026-54059 GHSA-8v84-f9pq-wr9xPillow is a Python imaging library. Prior to 12.3.0, PIL/PcfFontFile.py _load_bitmaps() read glyph dimensions from the PCF METRICS section and passed them directly to Image.frombytes() without calling Image._decompression_bomb_check(), allowing crafted PCF font data to cause excessive memory allocation. This issue is fixed in version 12.3.0.
- MEDIUMPYSEC-2026-4363 BIT-pillow-2026-112902 CVE-2026-112902 GHSA-xvh5-g6gv-559vPillow is a Python imaging library. In versions through 12.3.0, the libtiff TIFF encoder can pass arguments to TIFFSetField() that do not match libtiff’s definition of the corresponding tag. When an application saves attacker-controlled image metadata through this encoder, crafted tag values can cause invalid memory reads, copying process memory into the encoded output or crashing the process. Applications that return the encoded output to an attacker can disclose that memory. The issue is reachable when re-saving compressed TIFF images and through certain conversions that preserve EXIF metadata into compressed TIFF output. This vulnerability is fixed in version 13.0.0.
- MEDIUMPYSEC-2026-4337 BIT-pillow-2026-96636 CVE-2026-96636 GHSA-p8hx-v2p6-rp84Pillow is a Python imaging library. Prior to 13.0.0, MpoImageFile.seek() and DcxImageFile.seek() reparse later MPO or DCX frames and replace self._size without rerunning Image._decompression_bomb_check(). A crafted multi-frame image can use a tiny first frame to pass Image.open() and then declare an over-limit later frame. Normal frame iteration through seek(), load(), or ImageSequence.Iterator can decode that frame and commit hundreds of megabytes or more, causing memory-exhaustion denial of service. This issue is fixed in version 13.0.0.
- MEDIUMGHSA-fj7v-r99m-22gq BIT-pillow-2026-59198 CVE-2026-59198 PYSEC-2026-3494Pillow TGA RLE encoder can serialize up to ~57 KB of adjacent heap data into generated images
- MEDIUMPYSEC-2026-2257 BIT-pillow-2026-55798 CVE-2026-55798 GHSA-4x4j-2g7c-83w6Pillow is a Python imaging library. Prior to 12.3.0, WindowsViewer.get_command() constructed a cmd.exe shell command by directly embedding a file path into an f-string without escaping and passed the result to subprocess.Popen(..., shell=True), allowing shell metacharacters in the file path to inject arbitrary cmd.exe commands. This issue is fixed in version 12.3.0.
anyioPyPI 4.9.0 CRITICAL 4 advisories 4.14.2
- CRITICALGHSA-82r6-8w77-94w6 CVE-2026-63374 PYSEC-2026-4025AnyIO: TLSStream IDNA 2003 host name encoding enables potential TLS certificate spoofing
- MEDIUMPYSEC-2026-4024 CVE-2026-64847 GHSA-5p39-cfhj-2xmpAnyIO process-pool workers can block indefinitely on undrained stderr
- MEDIUMGHSA-5p39-cfhj-2xmp CVE-2026-64847 PYSEC-2026-4024AnyIO process-pool workers can block indefinitely on undrained stderr
- MEDIUMPYSEC-2026-4025 CVE-2026-63374 GHSA-82r6-8w77-94w6AnyIO: TLSStream IDNA 2003 host name encoding enables potential TLS certificate spoofing
certifiPyPI 2025.1.31 CRITICAL 2 advisories 2026.10.18
- CRITICALGHSA-6q48-6c7w-9gw2 PYSEC-2026-4320certifi bundles emSign root CAs with compromised intermediate CA keys
- MEDIUMPYSEC-2026-4320 GHSA-6q48-6c7w-9gw2certifi bundles emSign root CAs with compromised intermediate CA keys
h11PyPI 0.14.0 CRITICAL 2 advisories 0.16.0
- CRITICALGHSA-vqfr-h8mv-ghfj CVE-2025-43859 PYSEC-2026-348h11 accepts some malformed Chunked-Encoding bodies
- MEDIUMPYSEC-2026-348 CVE-2025-43859 GHSA-vqfr-h8mv-ghfjh11 accepts some malformed Chunked-Encoding bodies
starlettePyPI 0.46.1 HIGH 14 advisories 0.47.20.49.11.0.1+3 more
- HIGHGHSA-7f5h-v6xp-fcq8 CVE-2025-62727 PYSEC-2026-1942Starlette vulnerable to O(n^2) DoS via Range header merging in ``starlette.responses.FileResponse``
- HIGHGHSA-wqp7-x3pw-xc5r CVE-2026-48818 PYSEC-2026-2281Starlette: SSRF and NTLM credential theft via UNC paths in StaticFiles on Windows
- HIGHGHSA-82w8-qh3p-5jfq CVE-2026-54283 PYSEC-2026-249Starlette: request.form() limits silently ignored for application/x-www-form-urlencoded enable DoS
- MEDIUMPYSEC-2026-1941 CVE-2025-54121 GHSA-2c2j-9gv5-cj73Starlette has possible denial-of-service vector when parsing large files in multipart forms
- MEDIUMPYSEC-2026-161 CVE-2026-48710 GHSA-86qp-5c8j-p5mr X41-2026-002BadHost: Missing Host header validation poisons request.url.path, bypassing path-based security checks
- MEDIUMPYSEC-2026-249 CVE-2026-54283 GHSA-82w8-qh3p-5jfqStarlette is a lightweight ASGI framework/toolkit. From 0.4.1 until 1.3.1, request.form() accepts max_fields and max_part_size to bound resource consumption while parsing form data. These limits are enforced for multipart/form-data, but silently ignored for application/x-www-form-urlencoded. An unauthenticated attacker can therefore send a urlencoded body with an arbitrarily large number of fields or an arbitrarily large field, even when the application configured limits it believed would apply. This vulnerability is fixed in 1.3.1.
- MEDIUMGHSA-86qp-5c8j-p5mr CVE-2026-48710 PYSEC-2026-161 X41-2026-002Starlette has missing Host header validation that poisons request.url.path, bypassing path-based security checks
- MEDIUMPYSEC-2026-2280 CVE-2026-48817 GHSA-x746-7m8f-x49cStarlette is a lightweight ASGI framework/toolkit. In versions 1.0.1 and below, when dispatching a request, HTTPEndpoint selects the handler by lowercasing the HTTP method and looking it up as an attribute with getattr, without restricting the lookup to a known set of HTTP verbs. When an HTTPEndpoint subclass is registered through Route(...) without an explicit methods= argument, the route does not constrain the method and every method reaches the endpoint. If a non-standard HTTP method whose lowercased name matches an attribute on the endpoint subclass reaches the endpoint, that attribute is invoked as if it were a request handler. An attacker can use this to reach methods that were never meant to be HTTP handlers, such as internal helpers, without the authorization checks applied by the intended public handler. An application (including Starlette-based frameworks like FastAPI) is affected if it registers an HTTPEndpoint subclass via Route(...) without explicitly setting methods=, and that subclass includes extra methods named like non-standard HTTP verbs that take one request argument and return a response. This issue has been fixed in version 1.1.0.
- MEDIUMGHSA-x746-7m8f-x49c CVE-2026-48817 PYSEC-2026-2280Starlette: Arbitrary HTTP method dispatched to `HTTPEndpoint` attributes via `getattr`
- MEDIUMGHSA-2c2j-9gv5-cj73 CVE-2025-54121 PYSEC-2026-1941Starlette has possible denial-of-service vector when parsing large files in multipart forms
- MEDIUMPYSEC-2026-248 CVE-2026-54282 GHSA-jp82-jpqv-5vv3Starlette is a lightweight ASGI framework/toolkit. Prior to 1.3.0, the HTTP request path is not validated before being used to reconstruct request.url. Because request.url is rebuilt by concatenating {scheme}://{host}{path} and re-parsing the result, a path that does not begin with / (for example @google.com) moves the authority boundary during re-parsing, so request.url.hostname and request.url.netloc become attacker-controlled. Code that reads request.url.hostname (rather than the Host header or scope) can therefore be misled into trusting an attacker-supplied host. This vulnerability is fixed in 1.3.0.
- MEDIUMPYSEC-2026-1942 CVE-2025-62727 GHSA-7f5h-v6xp-fcq8Starlette vulnerable to O(n^2) DoS via Range header merging in ``starlette.responses.FileResponse``
- MEDIUMPYSEC-2026-2281 CVE-2026-48818 GHSA-wqp7-x3pw-xc5rStarlette is a lightweight ASGI framework/toolkit. In versions 1.0.1 and earlier, StaticFiles on Windows is vulnerable to SSRF. An UNC path such as \\\\attacker.com\\share can cause os.path.realpath to initiate an outbound SMB connection before the path is rejected, exposing the service account’s NTLMv2 credentials for offline cracking or relay even though the HTTP response is only a 404. The issue affects default follow_symlink=False deployments, including frameworks built on Starlette such as FastAPI; POSIX systems and follow_symlink=True are unaffected. The issue is fixed in 1.1.0.
- LOWGHSA-jp82-jpqv-5vv3 CVE-2026-54282 PYSEC-2026-248Starlette: Unvalidated request path concatenated into authority poisons request.url.hostname
idnaPyPI 3.10 MEDIUM 2 advisories 3.15
- MEDIUMGHSA-65pc-fj4g-8rjx CVE-2026-45409 PYSEC-2026-215Internationalized Domain Names in Applications (IDNA): Specially crafted inputs to idna.encode() can bypass CVE-2024-3651 fix
- MEDIUMPYSEC-2026-215 CVE-2026-45409 GHSA-65pc-fj4g-8rjxInternationalized Domain Names in Applications (IDNA) for Python provides support for Internationalized Domain Names in Applications (IDNA) and Unicode IDNA Compatibility Processing. In versions prior to 3.15, payloads such as `"\\u0660" * N` or `"\\u30fb" * N + "\\u6f22"` utilize the `valid_contexto` function prior to length rejection, and for high values of `N` will take a long time to process. This is the same issue as CVE-2024-3651, however the original remediation in 2024 was not a complete fix. A specially crafted argument to the `idna.encode()` function could consume significant resources. This may lead to a denial-of-service. Starting in version 3.14, the function rejects long inputs as soon as practicable prior to any further processing to minimize resource consumption. In version 3.15, this approach was extended to lesser used alternate functions (i.e. per-label conversions and codec support). A workaround is available. Domain names cannot exceed 253 characters in length. If this length limit is enforced prior to passing the domain to the `idna.encode()` function, it should no longer consume significant resources. This is triggered by arbitrarily large inputs that would not occur in normal usage, but may be passed to the library assuming there is no preliminary input validation by the higher-level application.
pygmentsPyPI 2.19.1 MEDIUM 2 advisories 2.20.0
- MEDIUMPYSEC-2026-2987 CVE-2026-4539 GHSA-5239-wwwm-4pmqPygments has Regular Expression Denial of Service (ReDoS) due to Inefficient Regex for GUID Matching
- LOWGHSA-5239-wwwm-4pmq CVE-2026-4539 PYSEC-2026-2987Pygments has Regular Expression Denial of Service (ReDoS) due to Inefficient Regex for GUID Matching
python-dotenvPyPI 1.0.1 MEDIUM 2 advisories 1.2.2
- MEDIUMPYSEC-2026-2270 CVE-2026-28684 GHSA-mf9w-mj56-hr94python-dotenv reads key-value pairs from a .env file and can set them as environment variables. Prior to version 1.2.2, `set_key()` and `unset_key()` in python-dotenv follow symbolic links when rewriting `.env` files, allowing a local attacker to overwrite arbitrary files via a crafted symlink when a cross-device rename fallback is triggered. Users should upgrade to v.1.2.2 or, as a workaround, apply the patch manually.
- MEDIUMGHSA-mf9w-mj56-hr94 CVE-2026-28684 PYSEC-2026-2270python-dotenv: Symlink following in set_key allows arbitrary file overwrite via cross-device rename fallback
Past security advisories
Vulnerabilities published for this server itself, from the GitHub Advisory Database.
No security advisories have been published for this server in the GitHub Advisory Database.
How it runs
| Where it runs | On your machine, started by your MCP client from this repository or its package |
|---|---|
| Transport | stdio |
| Sign-in | not checked needs the live server |
| MCP SDK | mcp ==1.30.0 |
| Servers in the code | 1 (AltiumMCP) |
The project's own security
| Security policy | none no SECURITY.md in the repository: report issues privately through GitHub if it is enabled |
|---|---|
| Past advisories | none in the GitHub Advisory Database |
| Last push | 2026-11-14 |
| Signed releases | not checked yet |
Where it is published
| Listed in | 4 catalogs (awesome_tensorblock, github_search, glama, mcp_toplist) |
|---|---|
| License | MIT |
| Created | 2025-03-27 |
Attack map
How the server is built and where its risky tools lead: servers, their tools, what the tools' code can do, and the traced route from a declared risky tool's argument to the operation it reaches. Click a node for details.