KiCad Script Hack For Better Mechanical CAD Export

Open source EDA software KiCad has been gaining a lot of traction recently. CERN has been devoting resources to introduce many new advanced features such as differential pair tracks, push and shove routing and this plenty more scheduled in the pipeline. One important requirement of EDA packages is a seamless interface with mechanical CAD packages by exporting 3D models in industry common formats. This improves collaboration and allows further engineering designs such as enclosures and panels to be produced.

KiCad has had a 3D viewer available for quite a long time. But it uses the VRML mesh format (.wrl files) and there are compatibility issues which prevent it from rendering certain versions of VRML files. Moreover, the VRML mesh export is not particularly useful since it cannot be easily manipulated in mechanical CAD software. Recent versions of KiCad now offer IDFv3 format export – the Intermediate Data Format, a mechanical data exchange specification for the design and analysis of printed wiring assemblies. Taking advantage of this new feature, [Maurice] created KiCad StepUp – an export script that allows collaborative exchange between KiCad and FreeCAD.

A FreeCAD macro and a corresponding configuration file are added to the KiCad project folder. You start with .STEP files for all the components used in the KiCad design. The next step is to convert and save all .STEP files as .WRL format using FreeCAD. On the KiCad side, you use the .WRL files as usual. When you want to export the board, use the IDFv3 option in KiCad. When [Maurice]’s StepUp script is run (outside of KiCad) it replaces all instances of .WRL files with the equivalent .STEP versions and imports the board as well as the components in to FreeCAD as .STEP models. The result is a board and its populated components which can be manipulated as regular 3D objects.

To get started, download the StepUp source from the Sourceforge repository. [Maurice] has also built a large library of 3D models designed using FreeCAD’s parametric capabilities, consisting of .STEP and .WRL models for each component. If you require additional resources, check out online services such as GrabCAD and 3DContentCentral from where you can obtain .STEP models for almost all of the commonly used components. The StepUp download contains a Demo project and User Guide to help you get started. [Maurice] also includes another FreeCAD macro to help with scaling, moving and rotating models.

The script configuration file lets you set the path to your 3D models folder and assign a color to the PCB. It’s also possible to ignore certain classes of components (such as the smallest ones or those non-critical to mechanical layout) from being imported into FreeCAD. This can be useful to reduce loading time and file sizes. We took a shot at trying out this new script and work flow, and after a few hiccups, were able to successfully perform the transfer. If you have any feedback to provide, [Maurice] is keen to hear you out over at the kicad.info forum. The forum would also be a good place to ask for any help you need with KiCad StepUp.

The first video here shows installation and use of the StepUp script and the second one demonstrates it in action exporting the CrazyFlie quadcopter from KiCad to FreeCAD.

16 thoughts on “KiCad Script Hack For Better Mechanical CAD Export

      1. Importing Eagle 6.x lbr files is also possible, but I found it easier to use the cleaner community kicad libs.
        Many people ported popular libs already, and some of the community eagle libs are so filled with errata now its pointless to import these libs anyway. Note the more accurate Spark-fun and LadyAda libs will have 95% of what most people use anyway.

        Eagle went from a reasonable $250 for two machines tool, to a $1800 non-floating seat licence on par with high-end cad packages. Its a worse deal compared with Altium… and the sales rep was very rude.
        :-/

        Hackaday should hold a month-long port-a-package-for-the-holidays contest to help consolidate everyone’s work for eventual feedback into the kicad trunk repo. Creating packages is pretty simple, but so far organizing these to remove duplicate work is a herculean task.

        karma +1 for CERN
        =)

  1. Maybe I missed this, but there’s a new release candidate version of KiCAD, i.e. precompiled binaries for your favourite OS! Surely this itself is worthy of an mention. As soon as I get a project report and grant submission out of the way I’ll be giving the RC and the StepUp scripts a go, both of these are very exciting. I’ve been using the old stable for several commercial projects with my own inefficient and non-automated take at MCAD integration. Always seemed rather silly to be creating component models in inventor, exporting to stl, converting to vrml for KiCAD, and then going back in reverse to get a mechanical model. I’d usually only do this as a last step, and the inflexibility of the process would mean I wouldn’t change the mechanical design much, just fit everything you else around it. I look forward to being more efficient!

  2. Since the great CERN guys took the plunge, KiCAD is getting better and better EVERY DAY. Just make sure you build it from sources to have the latest improvements. The push & shove router is wonderful and really really fast (with shove and walk around options nicely implemented), it has differential pairs routing options, they have added options to semi-automatically tune track length, 3D rendered has improved a whole lot, etc. And best of all, it’s FREE as in freedom.

    1. I just updated my kicad StepUp adding a GUI
      I’ve moved all the script on the kicad StepUp tools Macro, giving the project 3 flavors:
      1. a script interface (as before)
      freecad kicad-StepUp-tools.FCMacro demo
      2. a Macro GUI
      freecad kicad-StepUp-tools.FCMacro
      3. a FreeCAD WorkBench
      just open a “.kicad_pcb” or “.emn” or “.kicad_mod” file from the File Menu of FreeCAD

      here the new video tutorial
      https://youtu.be/h6wMU3lE_sA

      https://kicad-info.s3-us-west-2.amazonaws.com/original/2X/1/1413d11c5ed9fd359123a554895f04273fe4a8f8.jpg

      Maurice

  3. Solvespace now has the ability to link IDF files into assemblies. You can also take measurements on the board. Keepout reguions are show with the latest nightly builds, but components are not imported yet – this is on my todo but demand seems very low at this point.

    On a related note, Solvespace 3.0 and up export color information in STEP files so it is pretty good for modeling 3d parts for inclusion in KiCAD. You can use FreeCAD for that too of course – FLOSS tools that work are good tools!

Leave a Reply to AMSCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.