FreeCAD scripts for PCB CAD/CAM
MIT License
fcad_pcb is yet another way to improve ECAD/MCAD collaboration between FreeCAD and KiCAD.
The original purpose of these tools was to do PCB milling in FreeCAD. It can do much more now.:
The fcad_pcb macro is written in Python and requires FreeCAD 0.17 or later to work properly.
Macro
> Macros..
and find the path in the field User macros location
cd <path/to/your/macros/directory>
git clone https://github.com/realthunder/fcad_pcb/
cd fcad_pcb/
git submodule update --init --recursive
At this time fcad is usable through the FreeCAD python console.
View > Panels > Python Console
dropdown menuimport
command to load fcad_pcb:
from fcad_pcb import kicad
Result: you are now ready to use fcad_pcb.
from fcad_pcb import kicad
pcb = kicad.KicadFcad(<full_path_to_your_kicad_pcb_file>)
pcb.makeCoppers()
Note: the file path syntax should be one of the following:
pcb = kicad.KicadFcad('C:/Users/fooDesktop/MyProject/MyPCBfilekicad_pcb')
Alternatively if you don't want to replace backslashes for a Windows system:
pcb = kicad.KicadFcad(r'C:\Users\foo\Desktop\MyProject\MyPCBfile.kicad_pcb')`
Generate these full solid objects ready to for the FEM workbench
from fcad_pcb import kicad
pcb = kicad.KicadFcad(<full_path_to_your_kicad_pcb_file>)
pcb.make(copper_thickness=0.035, board_thickness=1.53, combo=False, fuseCoppers=True )
#
# NOTE: KiCAD 5.99 and later added possibility to specify per layer thickness including
# dielectric layers. You are no longer required to explicitly supply thickness
# parameters in any of the function calls as shown above.
dictionary
instead.Use either integer
or layer name
integer
(0~31, 0
being the front and 31
the back)
layer name
for key.
Note: key None
can be used for default thickness.
pcb.make(copper_thickness={None:0.05, 0:0.04, 'B.Cu':0.09},
board_thickness=1.53, combo=False, fuseCoppers=True)
#
# NOTE: KiCAD 5.99 and later added possibility to specify per layer thickness
# including dielectric layers. You are no longer required to explicitly
# supply thickness parameters in any of the function calls as shown above.
pcb.setLayer('F.Cu')
pcb.makeCopper()
For local nets you have to specify full hierarchical name
pcb.setNetFilter('GND')
pcb.makeCopper()
pcb.setNetFilter('GND','VCC')
pcb.makeCopper()
In case you only want the shape without any intermediate document objects
from fcad_pcb import kicad
pcb = kicad.KicadFcad(<full_path_to_your_kicad_pcb_file>, add_feature=False)
# Or, you can set the parameter later
pcb.add_feature = False
# All the above makeXXX() calls now returns a shape without creating any features
# For example, if you want the complete fused copper layers.
# Note: 'thickness' can be a dictionary for per layer thickness
coppers = pcb.makeCoppers(shape_type='solid', holes=True, fuse=True)
Part.show(coppers)
Note: that there is a sample board to play with inside this repo: test.kicad_pcb
FreeCAD >= v0.17