Creating KiCAD Footprints and Step/WRL files


#1

Hi everybody, new at the forum and to KiCAD. I had been watching/reading some tutorials and decided to go for a simple Witty Cloud board mimic; almost everything was there except for a Right Angle Tactile Switch. Instead of substituting it by a different horizontal model I decided it was a good opportunity to create my first component. Not willing to spend too much time on it either I looked for an ‘already made’ step file for such a component, which I found on grabcad:

https://grabcad.com/library/it-1188e-kls7-ts3606-smt-right-angle-tactile-switch-1

alas, also with datasheets and dimensional drawings. This looked promising. Unfortunately, as cflin comments, no footprints were included in the step. No problem, I have dimensions, so ahead with creating it.

I opened the step file with FC (version info below):

OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.16117 (Git)
Build type: Release
Branch: releases/FreeCAD-0-18
Hash: dbb4cc6415bac848a294f03b80f65e888d531742
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Spanish/Spain (es_ES)

It opened nicely. Good. Now to KiCAD (info below):

Application: kicad
Version: (5.1.2)-2, release build
Libraries:
wxWidgets 3.0.4
libcurl/7.61.1 OpenSSL/1.1.1 (WinSSL) zlib/1.2.11 brotli/1.0.6 libidn2/2.0.5 libpsl/0.20.2 (+libidn2/2.0.5) nghttp2/1.34.0
Platform: Windows 8 (build 9200), 64-bit edition, 64 bit, Little endian, wxMSW
Build Info:
wxWidgets: 3.0.4 (wchar_t,wx containers,compatible with 2.8)
Boost: 1.68.0
OpenCASCADE Community Edition: 6.9.1
Curl: 7.61.1
Compiler: GCC 8.2.0 with C++ ABI 1013

Build settings:
USE_WX_GRAPHICS_CONTEXT=OFF
USE_WX_OVERLAY=OFF
KICAD_SCRIPTING=ON
KICAD_SCRIPTING_MODULES=ON
KICAD_SCRIPTING_PYTHON3=OFF
KICAD_SCRIPTING_WXPYTHON=ON
KICAD_SCRIPTING_WXPYTHON_PHOENIX=OFF
KICAD_SCRIPTING_ACTION_MENU=ON
BUILD_GITHUB_PLUGIN=ON
KICAD_USE_OCE=ON
KICAD_USE_OCC=OFF
KICAD_SPICE=ON

and opened the Footprint editor, created a new project library and edited it by hand. Saved it as a kicad_mod file and tried to import it with the latest build of Stepup WB (keeping it updated to date) on FC. Loaded the step file (OK), imported the footprint … nothing’s showing up.

Error report:
KISYS3DMOD=/

module_3D_dir=//…/

FC Version 018

VBO status False

FootPrint Loader C:/Users/juanm/Documents/Arduino/leds/shoeled_pcb/shoeled.pretty/Right Angle Tactile Switch.kicad_mod

Running the Python command ‘ksuToolsLoadFootprint’ failed:

Traceback (most recent call last):

File "C:\Users\juanm\AppData\Roaming\FreeCAD\Mod\kicadStepUpMod\kicadStepUpCMD.py", line 543, in Activated

kicadStepUptools.onLoadFootprint()

File "C:\Users\juanm\AppData\Roaming\FreeCAD\Mod\kicadStepUpMod\kicadStepUptools.py", line 7345, in onLoadFootprint

routineDrawFootPrint(content,name)

File "C:\Users\juanm\AppData\Roaming\FreeCAD\Mod\kicadStepUpMod\kicadStepUptools.py", line 11285, in routineDrawFootPrint

for pad in getPadsList(content):

File "C:\Users\juanm\AppData\Roaming\FreeCAD\Mod\kicadStepUpMod\kicadStepUptools.py", line 9764, in getPadsList

drill_x = float(data[1]) #/ 2.0

could not convert string to float: ‘(offset 0.45’

Though it says KISYS3DMOD=/, the KISYS3DMOD path is setup as D:/KiCAD/share/kicad/modules/packages3d/ in the KiCAD Stepup GUI General Preferencies at the Stepup WB in FC.

I don’t know which string is trying to convert (I suppose it is expecting to find a floating point number and finding text or an integer… and crashes)…

Tried to look for similar errors but found none… dead end…

So, I changed to following maui’s steps for converting the datasheet drawing into a footprint together with the 3D to generate the footprint from FC using Stepup:

  1. Part DN Copy (flattened model)
  2. Hide Original elements
  3. Hide all parts of the copy except the pads (that’s elements 001 and 002 plus fillets at the bottom)
  4. Select pads (first element (no numbering) plus 003 and 004)
  5. 3D object to 2D projection (Shape2DView, Shape2DView001 and Shape2DView002 created)
  6. Hide 3D pads (first element (no numbering) plus 003 and 004)
  7. Select Shape2DViews (the three of them) and use 2DObject (or DXF) to sketch (sketch_converted created)
  8. Select sketch_converted and use Discretize a shape/outline to a sketch (sketch001 created)
    NB: this step I have added it in the last tries as previously I was following a different maui tutorial which did not use it - in either of the two - using it or not - I get errors afterwards). I have also realized that maui says in one of his comments: “I have PMed the file with my 3D model projected and converted to sketch. It seems your 3D model has some geometry issue that will make the discretization fail… I repaired mine with some tricks before projecting it…” but he doesn’t explain either what was wrong nor what he did to repair the 3D file.
  9. Hide sketch_converted
  10. Rename sketch001 to Pads_TH_SMD
  11. Repeat steps 3-10 with the fillets (rest of 3d shapes hidden) - get Shape2DView003 and Shape2DView004, Sketch_converted001, sketch003, rename to Pads_NPTH
  12. Repeat steps 3-10 with switch body (elements 001 and 002, rest of 3d shapes hidden) - get Shape2DView005 and Shape2DView006, Sketch_converted002, sketch005, rename to F_Silks_0.16
  13. Create group, rename to RATSW (Right Angle Tactile SW) and move the three pads to the group folder
  14. Open ksu tools->demo->footprint_template.FCStd and copy the Ref#_1.0mm and Value#_0.8mm labels to the RATSW folder in my project. Close footprint_template.
    NB: I don’t like copying this (well, what I really don’t like is not knowing where these come from), how can I create the labels myself? Shortcuts are good for productivity but not good for learning…
  15. Modify font size on both labels to 1,00, change [REF**] to [SW**] and reposition close to the sketch [0,00 1,25 0,00], reposition Value also close to the sketch (no text change here) [0,00 0,25 0,00]
  16. No everything looks ready to export… select the RATSW group folder and click on Footprint editor and exporter. It asks for a path and name to save the file (RATSW.kicad_mod). This is the report:

[‘SW**’]
['Value ']
exporting new footprint
saving to C:/Users/juanm/Documents/Arduino/leds/shoeled_pcb/shoeled.pretty/RATSW.kicad_mod
Group
Sketch001
Sketch003
Sketch005
Text
Text001
2d closed path
2d closed path
Running the Python command ‘ksuToolsFootprintGen’ failed:
Traceback (most recent call last):
File “C:\Users\juanm\AppData\Roaming\FreeCAD\Mod\kicadStepUpMod\kicadStepUpCMD.py”, line 1623, in Activated
kicadStepUptools.PushFootprint()
File “C:\Users\juanm\AppData\Roaming\FreeCAD\Mod\kicadStepUpMod\kicadStepUptools.py”, line 16182, in PushFootprint
export_footprint(name)
File “C:\Users\juanm\AppData\Roaming\FreeCAD\Mod\kicadStepUpMod\kicadStepUptools.py”, line 16805, in export_footprint
drl_found=collect_drl(pth_ordered)
File “C:\Users\juanm\AppData\Roaming\FreeCAD\Mod\kicadStepUpMod\kicadStepUptools.py”, line 17420, in collect_drl
r2=p[2][1]; cx2=p[2][2]; cy2=p[2][3]
list index out of range

I also tried the tool to fix and autoconstrain the sketches without luck…

Reading on, I got to the footprint from dxf/image/pdf part… if I open the Image addon and use create a flat image on the 3d space (use it-1188e-large.jpg for example or do a pdf cutout of the footprint image and save it as png with windows paint), select XY plane, click OK, reports:

Unhandled Base::Exception caught in GUIApplication::notify.
The error message is: Access violation

FC enters in a loop and keeps sputting these two lines on the report window every now and then and the 3D view becomes unresponsive.

So I can’t follow maui steps about using images as footprint templates either.

Any hints on why all these errors are coming up? Thank you.


#2

You could share the footprint here so that we can test.


#3

Hi eelik,

I don’t see how to upload files, I’ve shared a link to GDrive where I left the files I’m using. The footprints I made are not definitive (I want the fillets to be NPTH instead of TH Pads).

3D, datasheet and footprint files

Best regards,


#4

Hi @juanmadg
Your footprint is using ‘connector’ instead of ‘SMD’ for pads.
This will produce a wrong pcb, without the paste layer.

I have edited your fp, changing the pads from ‘connector’ to ‘SMD’ and this will load correctly.
Right Angle Tactile Switch-smd.kicad_mod (1.4 KB)


#5

Hi maui,

Thanks for the reply. I just loaded the footprint and I get this in the report window:

kicad StepUp version 9.0.2.5
tolerance on vertex applied
KISYS3DMOD=/
module_3D_dir=//…/
FC Version 018
VBO status False
FootPrint Loader C:/Users/juanm/Documents/Arduino/leds/shoeled_pcb/shoeled.pretty/Right Angle Tactile Switch-smd.kicad_mod
_Right_Angle_Tactile_Switch__fp
Unhandled Base::Exception caught in GUIApplication::notify.
The error message is: Access violation
Unhandled Base::Exception caught in GUIApplication::notify.
The error message is: Access violation

As before, both lines keep repeating every few seconds and though now I can see the footprint in the 3D view, the 3D view is mostly unresponsive again.

BR,
Juan


#6

This could be an issue between FC0.18 and your video card.
Try to load the FC0.18.3 from here: FreeCAD-0.18.16131
FreeCAD/releases/tag/0.18.3


#7

Hi @maui,

Uninstalled previous Freecad 0.18.2 and installed FC0.18.3 with the same results.

OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.16131 (Git)
Build type: Release
Branch: releases/FreeCAD-0-18
Hash: 3129ae4296e40ed20e7b3d460b86e6969acbe1c3
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Spanish/Spain (es_ES)

Report:

PoM not present
using ‘Part’ container
FC Version 018-16131
kicad StepUp version 9.0.2.5
tolerance on vertex applied
applying Materials to Shapes
your home path is C:\Users\juanm
export to STEP False
Tabified done !
done!
KISYS3DMOD=/
module_3D_dir=//…/
FC Version 018
VBO status False
FootPrint Loader C:/Users/juanm/Documents/Arduino/leds/shoeled_pcb/shoeled.pretty/Right Angle Tactile Switch-smd.kicad_mod
_Right_Angle_Tactile_Switch__fp
Unhandled Base::Exception caught in GUIApplication::notify.
The error message is: Access violation
Unhandled Base::Exception caught in GUIApplication::notify.
The error message is: Access violation
Unhandled Base::Exception caught in GUIApplication::notify.
The error message is: Access violation
Unhandled Base::Exception caught in GUIApplication::notify.
The error message is: Access violation
Unhandled Base::Exception caught in GUIApplication::notify.
The error message is: Access violation

BR
Juan


#8

This seems to be an issue related to some Py3/Qt5 FC version and OpenGL drivers.
duckduckgo search “Unhandled Base::Exception caught in GUIApplication::notify. The error message is: Access violation”

  1. In some user case this has been solved updating the video drivers.

  2. You can also have a try with a previous release of FC 0.18.1 which has Py2/Qt4
    FC download/0.18.1/FreeCAD_0.18.16110_LP_11.11_PY2QT4-WinVS2013_x64_portable.7z

  3. I would suggest to try even FC0.19 pre but consider that this release is moving toward new powerful features, and at the moment this release cycle is less stable than FC0.18.


#9

Hi @maui

You might be totally right. I just installed all the setup in a different environment (computer) and now the footprint loads without errors in FC. I’m not sure if it might be an issue that I already had python 2.7.15 and QT5.12 installations on the computer where the problems arose. I’m afraid the only way of testing that thoroughly would be to setup a VM with a clean OS and reinstall FC and KiCAD in it.

Once the footprint loaded, I have used compound to make an union of the switch parts and generated a step and wrl files. As my (shoeled) library is a project library, where should I place these files for the KiCAD footprint 3D viewer to show the 3D shape? I have tried dropping them at the project folder, shoeled.pretty (project library) folder and at a new library folder at KiCAD’s 3D shapes folder kicad\share\kicad\modules\packages3d\shoeled.3dshapes\ without no luck… (I already checked the show 3D shapes options in 3d viewer are selected).

BR
Juan


#10

you may have a look at here:


#11

Hi @maui

Thanks for the support. I got it yesterday afternoon.

I have setup a Win10 VM on the same computer with the problem (which is the one I use for all the stuff I do) but, although FC starts on the VM, it renders a black screen once I load the step file (any file really, even it own examples - everything is there as I can open the menus and browse through them once they drop down but you can’t see them, nor the toolbars nor the different windows). I suppose it doesn’t have enough resources and it’s already up to the limit of what the host OS can give and still keep running. I will just copy the files back from the other computer and keep working on the other one.

This really looks nice:



Thanks again for your guidance, maui.

NB: I was going to upload the resulting files in case anybody would need them but I’m a nooby and I’m not allowed to upload attachments to the forum.

BR
Juan


#12

Notice that the copyright holder of the switch 3D model owns all rights to that file and hasn’t given permission for redistribution. Legally we aren’t allowed to redistribute it.

This seems to be a common problem in the 3D model world. Nobody cares about the copyright issues, even big companies don’t give an explicit licence. Everyone just assumes something.


#13

Hi @eelik

What license type would be prefered? I can contact the author and ask him (without warranties that he will answer me or grant the license but who knows).

BR,
Juan


#14

No worries…got it here: http://kicad-pcb.org/libraries/license/

I’ll ask the author.

BR,
Juan