KiCad - script based creation of component 3D models in FreeCAD - RM84/84 and G3MB examples

Hi,

In my work, especially the one related to my teaching and hobyyist activity I always prefer using the Open Source environment. Therefore KiCad is may favorite schematic and PCB tool.

Unfortunately, this tools sometimes doas not provide all needed part symbols and models, so it necessary, that either me or my students have to create them ourselves.

(Well, I know, there are websites like

formatting link
but when I read all the limitations in their "Standard terms and conditions of use" all the limitations, I rather prefer to spend some time on preparation of something, that I can freely share with the whole Open Source Community).

Last time I needed to create the footprints and 3D models for two elements:

1) The power relay RM84/RM85
formatting link
formatting link
2) The solid state relay G3MB
formatting link

I found a wonderful 3 part description, which suggests using OpenSCAD or FreeCAD and then Wings3D:

formatting link
formatting link
formatting link

I have prepared a script, which generates the 3D model of RM85 in OpenSCAD. It is available in the archive as RM85.scad. It generates a perfect model, which can be saved as STL, converted by the meshlab to binary STL, imported to Wings3D and saved as WRL. However in that process you loose the color information (when OpenSCAD generates the STL), so you must manually add that information in Wings3D.

I like the script based method used by OpenSCAD. It is a perfect solution when you have just drawing of the component and its dimensions published in the datasheets. So I decided to try to use this approach with FreeCAD. Unfortunately, the documentation for FreeCAD is not oriented on creation of models in scripts, but in the Python console it displays the Python commands performed during the menu driven operations. Basing on that, and on documentation found at

formatting link
I've managed to prepare the appropriate scripts.

The interesting thing is, that this method allows one to avoid using Wings3D at all. The FreeCAD (version 0.15) is able to export the WRL file which may be used by the currect KiCAD (version 4.0.2)!

In my archive there are two files G3MB.py and RM85.py, which may be executed simply by: $ freecad G3MB.py $ freecad RM85.py Unfortunately, it is necessary to run them on a X11 capable console. Otherwise, the commands from FreeCADGui fail.

The attached archive contains:

1) Scripts G3MB.py and RM85.py, which generate the WRL files 2) directory WZ_Relays.pretty with PCB footprints associated with the generated WRL files (with appropraite rotation and scaling) 3) directory WZ_Relays.3dshapes (with generated WRL files)

The above files are published as PUBLIC DOMAIN (or Creative Commons CC0)

4) The WZ_Relays.lib - is the schematic symbol for the G3MB component and RM84 component. However for that I have reused standard KiCAD MOC3031M and RELAY_2RT symbols. Therefore this file is published under the original KiCAD library symbols license

The archive itself is available on the alt.sources group: Message-ID: Subject: "Creation of KiCad 3D models with scripts in FreeCAD - RM84/85 and G3MB models as examples - corrected, with RM85.scad"

Archive:

formatting link
(please remember to save the "original" format to be able to unshar the archive).

DISCLAIMER

Of course all submitted files are provided for free WITHOUT ANY WARRANTY you use it ON YOUR OWN RISK. As RM84 RM85 and G3MB are used to controll the mains voltage, DOUBLE CHECK if my symbols and models are correct. I've tried to avoid mistakes, but I may have overlooked something. The symbols and models HAVE NOT been used for any hardware verified design yet!

With best regards, Wojtek Zabolotny

Reply to
(Wojciech M. Zabołotny )
Loading thread data ...

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.