Fritzing sketches from code
What this skill gives you
- A method to turn a net list (a list of which pins connect together) into one
.fzzfile with three views: breadboard, schematic, and PCB. - Two worked generators. Copy one and change the parts and nets.
scripts/build_fzz_battery_led.pyuses only parts that ship with Fritzing: a battery holder, a push button, a resistor, and an LED. Start here.scripts/build_fzz_header_led.pyshows how to write a custom part (a.fzpfile and four SVG files) into the sketch.
- A part checker,
scripts/check_core_part.py. It tells you if a core part has all of its image files. - A headless checker,
scripts/fritzing_export.py. It loads a sketch in Fritzing and writes the three views as SVG files. - A window checker,
scripts/fritzing_gui_shot.ps1(Windows). It takes a screenshot of the Fritzing window, so you can read the status bar. - The file-format facts in
references/fz-file-format.md. Read it before you write any.fzXML.
What was tested
- Tested: Windows 11 with Fritzing 1.0.x, installed in
C:\Program Files\Fritzing. Both example sketches inexamples/build, export to SVG, open in the Fritzing window with "Routing completed" in all three views, and pass the PCB design rule check. This was checked on 2026-11-07. - Not tested: macOS, Linux, Fritzing versions other than 1.0.x, autorouting, and circuits with more than a few parts.
Rules for Claude
- Do not guess a part's pins. Read its
.fzpfile and list its connectors. Compare them with the net list before you build. - Check every core part with
scripts/check_core_part.pybefore you use it. A part whose image files are missing draws blank. - Do not download a file without the user's yes, unless they gave you the link. Say the file name, the source, and the size. Put each download in its own new empty folder. Do not run anything from it.
- Do not say a sketch "works" because the generator ran. Fritzing must load it, and each view must show every part. Say what you did not check.
- The last check is a person's: they open the file in the Fritzing window and say what they see. Fix the generator, not the file by hand.
- Write the full name of each file and part every time.
Workflow
Find Fritzing and its parts library
- Windows (tested): Fritzing is at
C:\Program Files\Fritzing\Fritzing.exe. The parts library isC:\Program Files\Fritzing\fritzing-parts. The sample sketches are inC:\Program Files\Fritzing\sketches\core. Read them to copy the exact XML that Fritzing writes. - Linux (not tested for this repository): a Fritzing AppImage can be unpacked with its
--appimage-extractoption into a new empty folder. The parts library is thensquashfs-root/fritzing-parts. - macOS (not tested): the parts library is inside the Fritzing application. Look for a folder named
fritzing-parts. - The scripts read the parts library from the user's own Fritzing install. Set the environment variable
FRITZING_PARTSto that folder.
Check the parts
- List the parts you need and look each one up:
python scripts\check_core_part.py "C:\Program Files\Fritzing\fritzing-parts" <part name>. Add--all batteryto list every core part with "battery" in its title. - It prints
OKorMISSINGfor each part, the number of connectors, and the module id. A part that saysMISSINGdraws blank in the view whose image file is gone. - Example from the 2026-11-07 test install: the core part
screw_terminal_2_100millacks its schematic and PCB images, and the core partBattery block 9Vlacks its PCB footprint (jumper_2_100mil_pcb.svg). The core part4 x AAA Battery Mountis complete. - If no core part fits, draw one.
scripts/build_fzz_header_led.pyhas an example: one.fzpfile and four SVG files. - If a part from another source lacks a pin, copy the part, give it a new
moduleId, and add the connector. Add the pin to the breadboard SVG, the schematic SVG, and the PCB SVG.
Build
- Copy
scripts/build_fzz_battery_led.py. Change the parts, the hole names, the coordinates, and the nets. - Write the nets as a list of members. The script checks its own wiring against that list in all three views, and checks the PCB trace clearance.
- Choose the breadboard layout first, then the schematic, then the PCB. Use
references/fz-file-format.mdfor hole names, scales, layer names, and transforms. - For a part with bendable legs, copy the leg XML from a Fritzing sample sketch. Do not guess it (see "Things that went wrong").
Check
- Run
python scripts\fritzing_export.py "C:\Program Files\Fritzing\Fritzing.exe" <sketch.fzz> <new empty folder>. Read each line it prints. It writes<name>_breadboard.svg,<name>_schematic.svg, and<name>_pcb.svg. - Look at the SVG files as pictures. One way on Windows: write an HTML page that holds an
<img>of the SVG file, then runmsedge.exe --headless --window-size=W,H --screenshot=<out.png> file:///<page.html>. Read the PNG. The export shows copper only, not the silkscreen outlines. For a PCB picture with the outlines, screenshot the PCB view in the Fritzing window withscripts\fritzing_gui_shot.ps1and crop the board (the PCB pictures inexamples/were made this way). - For each part, check three things: it is drawn, its pins sit on the holes, and each wire end touches a pin.
- The SVG export does not draw ratsnest lines (the thin lines that show unrouted connections). So it cannot prove that Fritzing registered the connections. Open the sketch in the Fritzing window.
- Windows, in the real Fritzing window:
- Start
Fritzing.exe "<sketch.fzz>"withStart-Process. Wait 25 seconds. - Run
scripts\fritzing_gui_shot.ps1 -Out <png>for the current view, then with-Keys "^3"for the schematic view and-Keys "^4"for the PCB view. Read each PNG. - Look for "Routing completed" in the status bar of each view, and for green connector dots.
- For the design rule check, run the script with
-Keys "^+d" -Wait 5in the PCB view. A clean sketch shows "Your sketch is ready for production: there are no connectors or traces that overlap or are too close together." - Close the dialog and run
Stop-Process -Name Fritzing.
- Start
Report
- Say what you checked and how. Say what you did not check. Name the files you wrote with full paths.
- Tell the user how to open the file: in Fritzing,
File→Open.
Things that went wrong before
- A core part's image files are missing from the install. The part draws blank. Run
scripts/check_core_part.pybefore you use a part. - A part draws blank. Fritzing 1.0.x draws nothing when a breadboard SVG has no
<g id="breadboard">group. Wrap the whole content in that group. - A wire end looks right but is not connected. The
.fzfile must list each connection in both items. Write onelink()call per pair and emit both sides. - A part with bendable legs (LED, resistor, diode, battery holder). In the
.fzfile, the connector<geometry x y>is the body-side end of the leg line in the SVG, times the scale. The<leg>second point is the tip, relative to that point. For the 5 mm LED the tip offset is(0, 30.5172). For the battery holder it is(6.25, 0). Fritzing's own sample sketches show this. - Wrong scale. A scene unit is 1/90 inch. An SVG with
inunits scales by90 × width_in / viewBox_width. An Illustrator SVG with plainpxunits counts as 72 dpi, so multiply by 1.25. - A schematic terminal is not found. Some schematic SVG files hide the terminal inside a
<g>element, and some have no terminal at all. Read the SVG file and take the outer end of the pin line. The LED schematicled.svghas its terminals at (9.9005, 21.8165) for the cathode and (9.9005, 0.2165) for the anode, at 72 dpi. - A rotated part lands off its holes. Use the transform formulas in the reference file. Place a part by the position of one pin, not by its corner.
- Traces cross. Put the two traces on different layers. Through-hole pads join both layers, so no via is needed.
- Python. The scripts use only the standard library. They need no installed package.
Files in this skill
SKILL.md: this file.references/fz-file-format.md: the.fzzand.fzformat, with XML examples, scales, layer names, and formulas.scripts/build_fzz_battery_led.py: generator with core parts only (battery holder, push button, resistor, LED).scripts/build_fzz_header_led.py: generator that also writes a custom part (a 2-pin header).scripts/check_core_part.py: checks that a core part has all its image files.scripts/fritzing_export.py: the headless load-and-export check.scripts/fritzing_gui_shot.ps1: activates the Fritzing window, can send keys, and saves a screenshot (Windows).examples/battery_led.fzzandexamples/header_led.fzz: the sketches that the two generators wrote, with a picture of each view.