Mirror image of a board outline

I have drawn half of my board outline. Now I would like to make a mirror image of my board outline, and position it touching the original outline, so that they form a symmetrical, closed outline. Is there a way to do this in KiCad, or do I need to write a script to modify the .kicad_pcb file directly?

KiCommand might be an option: (Not sure it works in the stable release Works with kicad stable according to the readme file.) @HiGreg might know more.

There’s an easier way than Python to do that (if you use a nightly build):

  • select the stuff you’ve drawn,
  • press Ctrl-C (Edit->Copy), click on the lower/upper end of the outline (to select it as an anchor point
  • press Ctrl-V (Edit->Paste)
  • press F (to flip the selection) or R-Click->Flip
  • place the flipped copy where you like it.

Hope this helps,

1 Like

About nightly builds: Be aware that using them is connected to some risks.

Thanks, but I’m using 4.0.7. I guess scripting is the way to do it, then…

A tip for the future: complex outlines might be better designed in a CAD tool.

If you use Freecad for this you can even use Stepup to directly “push” your outline into a kicad pcb file. More details see: Kicad StepUp: The Sketcher for Getting to Blinky

For any other tool you can import dxf files into kicad.

For now you could try to install kicad nightly in a virtual machine, edit the pcb as described by @twl such that you have it mirrored and try to open that pcb file in kicad stable.

I just found out that KiCommand would work in kicad stable. (according to it’s readme file)


That’s actually how I created the half outline; I drew it in Inkscape and then exported a DXF. So, yes, maybe the best approach is to go back to Inkscape and do the mirror image there, then export and import the DXF again.[quote=“Rene_Poschl, post:6, topic:9310”]
For now you could try to install kicad nightly in a virtual machine, edit the pcb as described by @twl such that you have it mirrored and try to open that pcb file in kicad stable.

I thought KiCad stable was unlikely to be able to open files created by nightly?

If it only contains the outline it should be possible.

The problematic new features are footprints with rounded rectangle or polygon pads.
Differential pair settings (which are only added if you have at least one differential pair “trace” used in the pcb)

This assumes there is no bad bug that creates an invalid file for another reason.

1 Like

People might make the mistake of considering the current nightlies ‘safe’ because they have reached “freeze”. You might consider adding to the bottom ‘no, it isn’t safer because the project has been frozen pending release and this applies to release candidates also. always have full project backups’.

Yea i could have added a note that a bacup might be a good idea. I just assumed people would be smart enough to figure out that a bacup is a good idea if i already give that many warnings against using nightlies for production. (In this case using nightlies for this one process might be the best option instead of trying to develop some python script. That is why i suggested to install a nightly build inside a vm.)

FWIW, the script is trivial:

#!/usr/bin/perl -w

my $centerline = 145;

sub mirror {
    my ($keyword, $x, $y) = @_;
    $newx = $x - $centerline;
    $newx = -$newx;
    $newx += $centerline;
    return "($keyword $newx $y)";

while (<>) {
    s/\((start|end|xy)\s+([\d\.\-]+)\s+([\d\.\-]+)\)/mirror($1, $2, $3)/ge;

The rate of commits is very high, add that the library structure is in the middle of shifting to the v5 structure and occasional serious problems are inevitable

Maybe easy for gods of regular expressions.

1 Like

The regular expression matches the following:

  • Left parenthesis
  • One of the strings “start”, “end”, or “xy”
  • One or more whitespace characters
  • A floating-point number
  • One or more whitespace characters
  • A floating-point number
  • Right parenthesis

Then, it is replaced by the same thing, except that the X coordinate (first floating-point number) has been mirrored around $centerline.

@ppelleti KiCommand would likely work. If you want to go that route, I can help you work through it.

Thanks! However, I’m happy with my script. I already completed my board and sent it off to the fab.

I’d mostly just been wondering if KiCad provided a way to do it “out of the box” in the UI, and it appears the answer is no. Which is fine, I just wanted to know.


For what it’s worth, here is what the finished board looks like.

I drew the outline of the left half of the butterfly in Inkscape. I exported a DXF from Inkscape and imported that into the Edge.Cuts layer. For the filled copper zone (darker colored area), I exported a bitmap from Inkscape and then converted it to a zone using these instructions. The exposed copper markings on the wings were created by importing another bitmap into the soldermask layer.

I then created a mirror image of all of these (the board outline, the copper zone, and the wing markings) using my Perl script, to complete the right half of the butterfly.


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.