iTranslated by AI
Supplementary Notes for KiCad 7+: How to Easily Import Component Coordinates Drawn in Adobe Illustrator into KiCad
Background and Purpose
I wanted to quickly transfer the coordinates of board components drawn in Adobe Illustrator to KiCad.
At that time, I referred to this article by Hanachi (published in 2020):
👉 Quickly Import Board Component Coordinates Drawn in Adobe Illustrator to KiCad
However, as KiCad evolved from version 6 to version 9, the API changed a bit,
and some parts no longer work as is.
This article summarizes the method that actually worked with KiCad v9 and how to deal with the pitfalls.
What Didn't Work and How to Fix It
Pitfall 0: Coordinates Not Displayed in ExtendScript Toolkit CC!

Symptom
Nothing is displayed even after running the script.
Cause
You simply forgot to select the components (paths) in Illustrator.
Solution
Select the components before running the script.
It's really just that, but at first you might panic thinking "Huh, nothing shows up!?"
Pitfall 1: Script Cannot Be Executed in KiCad / execfile No Longer Works!
Symptom
Typing execfile("set_position-right.py") as in the blog post doesn't work.
Cause
KiCad 7 and later (including v9) use Python 3, and execfile() has been removed.
Solution
Instead, use this👇
exec(open("set_position-right.py", encoding="cp932").read())
On Windows, encoding="cp932" works fine.
If saved as UTF-8, just change to encoding="utf-8".
Also, the current directory (= execution folder) in KiCad is the location of the currently open .kicad_pcb file,
so place the script in the same directory.
Pitfall 2: FindModuleByReference No Longer Works!
Symptom
Running the script causes an AttributeError and stops.
Cause
KiCad's API has changed; FindModuleByReference is no longer available.
Solution
Replace it with FindFootprintByReference.
Also, note that the way to specify positions has changed slightly.
Adding pcbnew.Refresh() at the end will immediately update the GUI.
(The corrected commands are written below)
Overall Workflow Based on the Fixes (Illustrator → KiCad)
From here, this is the actual procedure reflecting the above fixes.
Following this order should work correctly even with KiCad v9.
① Export Coordinates from Illustrator
- Launch Adobe ExtendScript Toolkit CC.
- Use the script from Hanachi's blog as is.
#target "illustrator"
(function(){
var convMilli = 1 / (25.4 / 72);
try {
if (app.documents.length > 0 ) {
app.coordinateSystem = CoordinateSystem.DOCUMENTCOORDINATESYSTEM;
for(i = 0; i < app.selection.length; i++){
obj = app.selection[i];
prop = obj.property;
x1 = pt2mm(obj.geometricBounds[0]);
y1 = pt2mm(obj.geometricBounds[1] * -1.0);
x2 = pt2mm(obj.geometricBounds[2]);
y2 = pt2mm(obj.geometricBounds[3] * -1.0);
cx = x1 + (x2-x1)/2.0 ;
cy = y1 + (y2-y1)/2.0 ;
var rad = 0.0;
if(obj.tags.length > 0 && obj.tags[0].name == "BBAccumRotation"){
rad = obj.tags[0].value; //in radians
}
var angle = rad * 180.0 / Math.PI;
$.writeln( obj.name + "\t" + cx + "\t" + cy + "\t" + angle);
}
}
else{
throw new Error('no document');
}
}
catch(e) {
alert( e.message, "script error", true);
}
function mm2pt(mm) {
return mm * convMilli;
}
function pt2mm(pt) {
return pt / convMilli;
}
})()
- Make sure to select the components before running (nothing is output if nothing is selected).
- Copy the coordinates (
Ref name, X, Y, Angle) displayed in the Toolkit window.

② Prepare the KiCad Script
- Save the file as
set_position-right.py(or similar) in the same folder as your.kicad_pcbfile. - Copy and paste the following into the
.pyfile, then paste the coordinates you copied earlier intoparts = [...].
import pcbnew
OFFSET_X = 0.0
OFFSET_Y = 0.0
pcb = pcbnew.GetBoard()
def set_footprint_position(name, xp, yp, rot):
module = pcb.FindFootprintByReference(name)
module.SetPosition(pcbnew.VECTOR2I(pcbnew.wxPointMM(xp + OFFSET_X, yp + OFFSET_Y)))
module.SetOrientationDegrees(rot)
parts = [
"('SW1', \t1, \t0,\t0),"
"('SW2', \t5, \t0,\t0),"
"('SW3', \t9, \t0,\t0),"
"('SW4', \t13, \t0,\t0),"
"('SW5', \t17, \t0,\t0),"
"('SW6', \t21, \t0,\t0),"
"('SW7', \t25, \t0,\t0),"
"('SW8', \t29, \t0,\t0),"
]
for p in parts:
set_footprint_position(p[0], p[1], p[2], p[3])
③ Execute in KiCad
- Open Tools → Script Console in KiCad.
- Type the following line and execute it.
exec(open("set_position-right.py", encoding="cp932").read())
If saved as UTF-8, change to encoding="utf-8".
When executed, you'll see output like [OK] SW1: (1.000, 0.000) mm, 0° in the console, and if the components are aligned, it's successful.
Before execution

After execution
Comparison of the KiCad board before and after execution (before / after)
Summary
- In KiCad v9,
execfile()cannot be used, so replace it withexec(open(...)). - It is safest to place the
.pyfile in the same folder as.kicad_pcb. - Change
FindModuleByReferencetoFindFootprintByReference. - Don't forget
pcbnew.Refresh().
With these steps, you can quickly align components in KiCad v9 based on coordinate output from Illustrator.
Discussion