Kicad StepUp: The Sketcher for Getting to Blinky


I am making very good use of StepUp these days in my current project. Thanks so much maui for providing these great utilities. As I understand from the above, what you want to do to update the PCB edge is to re-import the board into FreeCad with StepUp, and replace the sketch in that imported file with the original saved one with the constraints. However when I do that I am getting an offset in the position of the PCB edge. I am not sure I understand the last point, which could be my problem: Were in KiCad are one to set a PCB file static design reference to the preferred choice Grid Origin? Does that differ from the default setting?
[edit: to make it clear, the offset already appears in FreeCad after replacing the new sketch without constraints with the old one with the constraints].

What has worked for me without producing an offset is a manual procedure: Rename/make backup of the edited Pcbnew file. Let KiCad create a new blank pcbnew file. Import that into FreeCad and copy the sketch of the saved FreeCad file that has the board outline with the constraints to replace the original blank sketch and edit it to your liking. Save it and push the edge back to the blank PCBnew file. Edit the PCBnew file that now has the updated edge with a text editor and replace everything except the PCB edge with the information from the original renamed PCBnew file. (I found the board edge is conveniently placed at the very end of the PCBnew file so it is very easy to do these edits in a text editor).


If you start designing with that assigned, everything will be kept aligned.
I forgot one information above: you need to configure also StepUp to use Grid Origin (as suggested in the Cheatsheet)…
in ‘ksu-config.ini’ set:

placement = usegridorigin
;; placement options
;placement options: useauxorigin, usebaseorigin, usebasepoint;x;y, usedefault, +autoadjust

I edited/placed this info also above now.


Thanks for the explanation maui. I tried doing as instructed, however it seems to be sensitive to where grid origin is placed. In the first attempt I centered the grid origin in Pcbnew. That lead to a 1.6 mm offset in both x and y plane after the exchange back and forth. Then I tried grid origin in the upper left corner, but got a large offset. Third attempt with a centered grid origin again gave a medium large offset. In ksuconfig.ini I have placement = usegridorigin.

It seems to me that instead of re-importing the whole board into FreeCad for edit of board edge, one could have just had some code that would push the original constrained sketch to the pcbnew file, by essentially doing the same edit as I did with my text editor. This would avoid any problems with grid origins, as it would just be a repeat of the initial export of pcb edge to the board.

Application: kicad
Version: (2017-11-03 revision 08a9dc01c)-makepkg, release build
wxWidgets 3.0.3
libcurl/7.54.1 OpenSSL/1.0.2l zlib/1.2.11 libssh2/1.8.0 nghttp2/1.23.1 librtmp/2.3
Platform: Windows 7 (build 7601, Service Pack 1), 64-bit edition, 64 bit, Little endian, wxMSW
Build Info:
wxWidgets: 3.0.3 (wchar_t,wx containers,compatible with 2.8)
Boost: 1.60.0
Curl: 7.54.1
Compiler: GCC 7.1.0 with C++ ABI 1011

Build settings:


No, it shouldn’t…

this would break the connection between the Sketch and the mechanical design, for example when checking for enclosure collisions…
The most straight way is to follow the suggested sequence…
What is normally done is to place the grid origin to a drill center (i.e. the pin #1 of a connector), then all your measures will be referenced to that origin, both in KiCad and in FreeCAD.

I attached a test-board self containing project… (356.4 KB)
I placed the Grid Origin to pin#1 of the pin-headers connector
Could you please have a try in push and pull with this board to see if in your configuration is it working with this board?


Thanks for the the followup, maui. I can confirm that the attached test board worked pushing the version with the rounded edge back to the pcbnew file without creating an offset. Apparently I am doing something incorrectly with my own boards in KiCad. I assume the grid origin in FreeCad is read from the KiCad pcbnew file and does not have to be defined separately in FreeCad?

I will experiment some more. I am pretty inexperienced with using the grids in FreeCad, but I found out I could display the 3d grid and confirm the location of the grid origin in the file you supplied, so that gives me something to work on with my own boards.

BTW I am using development versions of both FreeCad and KiCad, both only a few days old.
(KiCad version in my last post).
OS: Windows 7
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.12539 (Git)
Build type: Release
Branch: master
Hash: adc24f8c8ffb81ce5b85af9ac6ed67054ae0030d
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.1.0
Locale: English/UnitedStates (en_US)


After some more experimentation, it could look like my problem was that I started out with a completely blank board, with just the grid origin defined (or no grid origin before I became aware of that), no edges or components on the board. Perhaps that prevented the grid origin to be saved. With a simplified board as a starting point with defined grid origin, the interchange back and forth works now (several times) without creating any offset.


Hi @otoien
thank you for testing this latest implemented feature…

I see if I can attach the grid origin to the sketcher also when the board is without a basic starter edge.

For the moment I updated the description as for your workflow.



Hi @otoien
now it should work also with empty boards… the only requirement is to place the grid origin since the beginning.
(update ksu from FC tools)

I just noticed that placing grid origin will not trig any changing to pcbnew, so the Save button will not be enabled…
This is a bug that I would file to launchpad.
Thanks again for testing


Hi @maui
Thanks for looking further into this. The bug could help explain my initial problems. Good to be aware of this so that one can make some other changes to the board that will enable the save.


Hi, @maui.

I have some questions:

  1. Say I have come up with a sketch to be used as board edges, but the sketch is in another FreeCAD file, e.g. the pcb is mounted on a flange, whose 3d model was used to define the edge of the pcb. How can I push that sketch into my pcb? Perhaps importing it using your assembly2 workbench (another superb contribution to FreeCAD)? If I try to push the sketch into a pcb, either nothing happens or FC tells me I should import the pcbnew file first (in which case it opens a second sheet for it). In either case, a mysterious “Shape” object appears directly under the root of the original mechanical document. Something weird happens because I get errors in the FC report window (‘Sketch004’ is the name of the sketch I am trying to push):

pcb edge does not exist, aligning sketch to Grid Origin
Traceback (most recent call last):
File “/home/cf/.FreeCAD/Mod/kicadStepUpMod/”, line 13195, in onPushPCB
File “/home/cf/.FreeCAD/Mod/kicadStepUpMod/”, line 13531, in PushPullPCB
File “/home/cf/.FreeCAD/Mod/kicadStepUpMod/”, line 16222, in export_pcb
File “/home/cf/.FreeCAD/Mod/kicadStepUpMod/”, line 15754, in Discretize
sketch = Draft.makeSketch(FreeCAD.ActiveDocument.getObject(newShapeList[0]),autoconstraints=True)
IndexError: list index out of range

  1. Does the board origin have to coincide with the layer alignment target?

  2. What exactly is the status of the zero-origin bug in the stable version of KiCAD? I was not able to make much sense from that thread.

  3. Pertaining to the above (somewhat), I find it weird that KiCAD does not allow a save if it thinks nothing has changed. Why? I may just want to force a save regardless of changes, perhaps for my own bookkeeping based on time stamps.

I have the latest stable version 4.0.7 version of KiCAD for Ubuntu (KiCAD does not provide a means to copy its version info to the clipboard, unlike FC, and says “© 1992-2015” despite the fact that the latest version came out either this year or late last year). And here is the info about FreeCAD, the latest version I updated with today:

OS: Ubuntu 16.04.4 LTS [Note: For some reason, KiCAD reads it as 16.04.1]
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.13325 (Git)
Build type: None
Branch: master
Hash: 77c1fc59e4732d52e04a2846f83fb01a839bc589
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.1.0
Locale: English/UnitedStates (en_US)


StepUp allows to push a Sketch to a PCB in these cases:

  1. the kicad board file is empty or doesn’t contain already a pcb edge…
  2. the sketch is inside a stepup imported board
    If your skecth is in a different FC file, just copy and paste it into the FC file generated while importing your kicad_pcb

to be pushed to a kicad board, the sketch must have a contiguous outline and there must be no overlapping or doubled edges
Could you share your sketch? or send it by PM?

no, you need to configure ksu to use grid origin

placement = usegridorigin

Having the Save button disabled until nothing has changed is useful to know if you have or not changed anything to your board (similarly to what you have in a text editor)… If you want to save the board regardless of changes, just use ‘save as’ menu and use the same name…


@maui: OK, I will pm you the a file with the 3D model of the flange (which is not a solid, as defined in FC, but the sketcher, somehow, agreed to bind to flat surface on that flange!) with the sketch on it. Ironically, the sketch was also used to build a 3-D model of the pcb itself, which, unfortunately cannot be pushed to KiCAD because KiCAD does not understand 3D, and neither is it required to.

One more thing: I did declare a grid origin in pcbnew, pcbnew clearly displays it, but when I bring the cursor very close to, if not on top of, the grid origin, the coordinates I read are way different than (0,0).

What is that ‘Shape’ object that appears directly under the document root when I try to push the sketch into KiCAD? It makes no difference if I make ‘Shape’ visible or invisible—I see nothing.


thx I will have a look at :slight_smile:

this means the script run into an error in converting the sketch to a pcb edge…
which is your report panel output?

from the manual
“3.11. Right-hand side toolbar”

Grid origin. (grid offset). Useful mainly for editing and placement of footprints. Can also be set in Dimensions/Grid menu.

it will help in placing footprints at a right snap… it is an internal reference I used for having an absolute reference when exchanging data between FC and kicad


Thanks for the file…
I’ve found the issue… it is related to Points in the sketch… I normally place them in construction geometry, but I should have dropped them anyway… I’ve patched the ksu to let you keep them safe :wink:
Please update it through FC tools menu.
Patched release “”


Thanks, I was aware of that documentation. It is cryptic. It does not clarify how it is “[U]seful mainly for editing and placement of footprints” and what difficulties the user may face if that option is not used. Furthermore, the documentation says it can also be set from the Dimensions/Grid menu. Well, in my latest version of KiCAD (4.0.7), I see,on the top, separate menus for dimensions and grid, and neither of them gives the option of setting the origin.


dimensions -> grid
This gives the option to set the origin for the grind. Not the origin for the file coordinates.


I can attest this procedure works perfectly now, after updating to maui’s latest version of StepUP. The placement of the board edges is very critical to the project I am involved with now because I need to place a camera chip. So, just to test the upgraded files by maui, I erased the edges of my board (after backing it up), made up a new random polygonic board edge (otherwise, without board edges, FC complains and prompts to check the board edges), and imported the pcbnew file into FC. That opened a second sheet the the pcb. I used CTRL-C CTRL-V to copy the sketch from the first sheet to the second one with the pcb.

Now the fun began. The copied sketch was on a different plane from the top of the pcb. So, I picked one point from the sketch and the top plane of the pcb, and used maui’s Assembly 2 workbench to impose a planar constraint between the point and the plane, thus forcing the sketch on the top plane of the pcb. I then imported the sketch into the pcb and inspected the result in KiCAD. It was dead on! (I know because I had drawn, on the drawing plane, lines to help me determine the exact placement of the board edge with respect to the grid origin.)

Thank you, maui, for your excellent work!


Thank you! My bad!

As a note, using the menu you display, I clicked on “Reset Grid Origin.” KiCAD obeyed and also the “Save” button became selectable. I am stating this because an issue was raised earlier about KiCAD not considering changes to grid origin worthy of saving.


Thank you for your positive feedback :smiley:
I think the Sketcher in FreeCAD could help a lot when the pcb edge is complex or have to be re-worked during the designing process…

I didn’t make Assembly2 WB, I just collaborate to let it work with FC 0.17 and added some useful constrains…

You may also find useful the manipulator WB that I developed later to improve some functionalities…
The Aligner tool can align also hierarchical objects, feature not available in A2 WB…
EDIT: updated the link