main
Colby Knox 0.2.58 source (not yet released, needs signing): autoroute, layer_stack, rule descriptors, sch_zoom f82b5b5 11h ago

name: altium-schematic-edit description: >- Edit an existing Altium design's schematic and push it to the board, the way an engineer does at the sheet: place a library part (altium_sch_place_part), connect pins with net labels or power ports (altium_sch_connect), move/rotate/rename/re-comment/delete parts (altium_sch_edit), number '?' designators (altium_annotate), set the title block (altium_doc_params), write part parameters (altium_sheet_params), carry the changes to the board with a previewed engineering change order (altium_update_pcb), and print the schematic to PDF (altium_export_pdf). Use when asked to add a part, wire something up, change a value, rename or delete a component, annotate, update the PCB from the schematic, fill in the title block or export a schematic PDF in Altium. Trigger words: add a resistor in altium, place a part, connect pin, net label, power port, gnd symbol, change value, rename designator, delete component, annotate, update pcb, engineering change order, eco, import changes, title block, schematic pdf, altium_sch_connect, altium_update_pcb.

Parent skill: altium-bridge

altium-schematic-edit

Every verb takes paths on the Windows machine, edits in place with one undo step, and saves the sheet unless save:false. Read first, then edit: altium_schematic_data {filePath, pins:true} gives every part's designator, position (mils from the sheet's lower-left corner), orientation and pins.

Add a part and wire it

altium_sch_place_part '{"sheet":"C:\\proj\\Main.SchDoc","library":"C:\\proj\\Lib.SchLib","symbol":"RC0402-10K",
                        "designator":"R?","x":2500,"y":2500,"comment":"10k"}'
altium_annotate       '{"projectPath":"C:\\proj\\board.PrjPcb"}'                      # R? -> R9
altium_sch_connect    '{"sheet":"C:\\proj\\Main.SchDoc","connections":[
                         {"designator":"R9","pin":"1","net":"VOUT"},
                         {"designator":"R9","pin":"2","net":"GND","kind":"power"}]}'
altium_update_pcb     '{"projectPath":"C:\\proj\\board.PrjPcb"}'                      # preview
altium_update_pcb     '{"projectPath":"C:\\proj\\board.PrjPcb","execute":true,"timeout":600}'
  • sch_place_part copies the library part's drawing, parameters (MPN, Manufacturer, distributor numbers) and footprint links. footprint + pcbLib link a different footprint. Coordinates snap to 100 mil.
  • sch_connect draws a wire stub (default 200 mil) out of each pin's end and puts a net label on it (kind:"label"), a power port (kind:"power"; GND, AGND, VSS... get a ground symbol, other nets a bar) or nothing (kind:"wire"). Pins are matched by number first, then by name. Each connection answers ok or why not (pin not found on R9).
  • annotate gives every R?, C?, U? the lowest free number for its prefix across all sheets, top-left first. dryRun:true shows the plan. Multi-part components with ? are left to Altium's own Tools > Annotation (skippedMultiPart).

Find parts on the sheet (cross-probe)

altium_sch_zoom '{"sheet":"C:\\proj\\Main.SchDoc","designators":["U1","L1"]}'

Selects them, frames the view on them and returns a frame (notOnSheet names any that are not there). On the board, altium_zoom_to {designators} does the same.

Change parts

altium_sch_edit '{"sheet":"C:\\proj\\Main.SchDoc","edits":[
  {"designator":"R5","action":"comment","text":"4k7"},
  {"designator":"C9","action":"delete"},
  {"designator":"U2","action":"move","x":4000,"y":3000},
  {"designator":"U2","action":"rotate","degrees":90},
  {"designator":"R12","action":"designator","to":"R8"}]}'
altium_sheet_params '{"projectPath":"C:\\proj\\board.PrjPcb","designators":["R5"],"params":{"MPN":"RC0402FR-074K7L"}}'

Wires do not follow a moved or rotated part: reconnect with sch_connect. Every part of a multi-part component with that designator changes together.

Push to the board: altium_update_pcb

Altium's Design > Update PCB Document (from the board: Import Changes), the engineering change order.

  • Preview first (the default). preview.addParts are on a sheet but not the board; preview.removeParts are on the board but on no sheet. Those are often board-only test pads, fiducials and mounting holes, and the change order would DELETE them.
  • execute:true runs it, and refuses while removeParts is not empty unless allowRemovals:true. Put board-only parts on a sheet instead when they should stay.
  • The first change order on a board that was built by script asks to link parts by designator; the verb answers it. It presses Execute Changes, waits for every row to finish, closes, and saves the board (the change order edits it in memory only).
  • New parts land beside the board outline: place them with altium_move_parts, check with altium_routing_drc.
  • Pass timeout (seconds) for long verbs: ab waits for the call's own timeout.
  • Component comment changes alone do not open a change order on AD 26.11.1 (Altium's comparator found no differences for them); parts, nets and parameter changes do.

Title block and PDF

altium_doc_params '{"sheet":"C:\\proj\\Main.SchDoc","set":{"Title":"12 V to 5 V buck","Revision":"B","DrawnBy":"AI"}}'
altium_export_pdf '{"projectPath":"C:\\proj\\board.PrjPcb","board":true}'   # -> C:\proj\board.pdf

export_pdf prints every sheet (and the board's composite with board:true) through an OutJob in a throwaway project, so the user's project is not changed. When Altium's PCB Health Check stops the job (shelved or modified polygons, ...), the bridge answers Generate Outputs and lists what it said in healthCheck; healthCheck:"stop" on altium_run_outjob cancels instead.

Pitfalls

  • Two open projects with the same file names (a copy beside the original) confuse Altium's comparator: close the one you are not editing.
  • Sheet edits are saved; the board is saved by update_pcb after a change order. altium_close_document never saves.