Article 006 - Adding new commands to KiCad's PCB Editor

Adding New Commands to KiCad's PCB Editor


1. Introduction

As a long-time AutoCAD user, I often find working with other CAD packages frustrating. Autodesk has refined AutoCAD over several decades, and the result is an extremely efficient and intuitive workflow that experienced users quickly become used to. It isn't simply that I'm unfamiliar with KiCad's commands. Coming from an AutoCAD background, some parts of KiCad's workflow feel surprisingly cumbersome and inefficient.

While using KiCad for PCB design, I kept missing certain AutoCAD-style commands. To be fair, KiCad often has equivalent functionality, but it isn't always implemented the same way, and it isn't always as quick or intuitive for an AutoCAD user.

So I downloaded the latest KiCad source code and imported the project into Visual Studio 2022, which let me explore and modify the C++ codebase directly.

This article will evolve as the project progresses. My updates are on GitHub: github.com/Ian-Johnston/KiCad-modifications

2. Building KiCad in Visual Studio 2022

This took considerably more than simply opening the source code. KiCad is a large C++ application built with CMake and a substantial number of third-party libraries.

KiCadsource CMake + vcpkg100+ libraries Ninja buildin VS2022 cmake --installafter every build Rundebug build
StepWhat was involved
Source and CMake Downloaded the source code, opened the root folder directly in Visual Studio's CMake environment and configured the build system.
Dependencies A separate vcpkg package manager installation automatically downloaded and built over a hundred dependencies, including wxWidgets, Boost, OpenCascade and many supporting libraries.
Problems fixed Modified the CMake preset configuration. Diagnosed a build failure caused by an obsolete tar.exe from an Atmel development package, which CMake had picked up and cached.
Result KiCad configured, compiled and linked, producing a working debug build that launches from the generated installation directory. I now have a fully working Visual Studio environment for debugging and modifying KiCad.

Once Visual Studio and Ninja have compiled the source and created the executables and DLLs in the build tree, this command copies all the required runtime files into a structured installation directory:

"C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" --install build\msvc-win64-debug

That includes the KiCad executables, internal DLLs, plugins, scripting files, libraries, icons, translations and other runtime resources. It has to be run after every build in VS2022.

3. Update: Getting the Mods into KiCad

UPDATE 01/09/26

Good news! Another user has stepped forward and submitted my modifications to the KiCad developers, and by all accounts they're going to be included in an upcoming release.
UPDATE 24/07/26

Sadly, I found complying with KiCad's Merge Request (MR) process too much for me, so I won't be submitting my code to the team. I did install GitLab and Git, made a commit and raised an MR, but it failed, mostly on code formatting errors. I'm not entirely sure whether VS2022 caused some of these, but certainly some were self-inflicted, as the checks are quite strict. From what I can see, I'd need to run diffs from the command line to check each fix. I'm tired of the command line... it's 2026!

No offence to KiCad, it's just not for me, so my KiCad modifications stay with me for my own use. However, if you're an existing KiCad developer and want to take them on, please contact me.

Here's where I got to:

4. AutoCAD-Style Commands

CommandShortcutWhat it does
MATCHPROP SHIFT+Q Copies properties from one track or via to others.
EXTEND SHIFT+E Extends a straight track to the nearest boundary.
TRIM SHIFT+T Trims a straight track back to the nearest boundary.

All three commands work either way round: select the item first, then invoke the command, or invoke the command, then click the items. They're also on the right-click context menu when a suitable item is selected, and they stay active until you press ESC.

MATCHPROP

source next

Copies properties from one item to other similar items, such as tracks to tracks or vias to vias.

  • Select a source track or via, then press SHIFT+Q.
  • Click the target tracks or vias one after another. Each target takes on the source properties immediately.
  • You can also drag-select a group of tracks or vias.
  • Press ESC to finish.

EXTEND & TRIM

EXTEND (SHIFT+E) grows to the boundary TRIM (SHIFT+T) cut back to the boundary

In both commands the boundary is either a same-net track on the same copper layer, or a straight graphic line drawn as a temporary boundary.

Extend

Extends a straight track until it reaches the nearest suitable boundary.

  • Press SHIFT+E, then click near the end of the track to extend.
  • The endpoint nearest the cursor grows along the existing track direction until it meets a boundary.
  • From the right-click menu, the selected track is extended immediately, without selecting it again.

Trim

Shortens a straight track back to the nearest suitable boundary.

  • Press SHIFT+T, then click the part or end of the track to remove.
  • If the track passes through two boundaries, TRIM can remove the section between them, leaving each remaining piece ending at its intersection.
  • From the right-click menu, the selected track is trimmed immediately, without selecting it again.

5. Future Commands?

These are other AutoCAD commands I'd like to add.

MOVEFROM

Select one or more items, invoke the command, pick any reference point on the selection, then pick a destination point. The selection moves so the reference point lands exactly on the destination.

COPYFROM

As MOVEFROM, but a copy of the selection is placed with the reference point on the destination. The command stays active until ESC is pressed.

OFFSET

Select a line, arc, board outline or graphic object, enter an offset distance and click the side to offset. A new parallel object is created at that distance.

BREAK

Select a line, track or arc, then pick two points. The section between the two points is removed.

JOIN

Select two or more connected lines, arcs or tracks. The selected geometry is merged into one continuous object where possible.

STRETCH

Select geometry with a crossing window and drag a reference point. Only the vertices inside the window move, and connected geometry stretches to stay joined.

ALIGN

Select multiple objects and choose Left, Right, Top, Bottom, Centre Horizontal or Centre Vertical. The objects are aligned accordingly.

Source code for my modifications: github.com/Ian-Johnston/KiCad-modifications

 

↑ Top