• Stars
    star
    126
  • Rank 284,543 (Top 6 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 8 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

FreeCAD scripts for PCB CAD/CAM

FreeCAD scripts for PCB CAD/CAM & FEM

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.:

  • It can generate gcode from kicad_pcb directly without going through the gerber stage.
  • It can let your modify the PCB directly inside FC (done already),
  • and potentially export back to kicad_pcb (partially done).
  • and finally it can generate solid tracks, pads and plated drills to enable FEM and thermal analysis on KiCad pcb boards.

Installation

The fcad_pcb macro is written in Python and requires FreeCAD 0.17 or later to work properly.

  1. Clone this repo into your freecad macro directory. To check what the default path of your macro directory is go to dropdown 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/
  2. Enter the locally cloned repository
    cd fcad_pcb/
  3. Download the repository submodules
    git submodule update --init --recursive
  4. Restart FreeCAD

Usage

At this time fcad is usable through the FreeCAD python console.

  • Start FreeCAD,
  • Launch the python console Enable through the View > Panels > Python Console dropdown menu
  • Invoke the python import command to load fcad_pcb:
    from fcad_pcb import kicad

Result: you are now ready to use fcad_pcb.

Generating copper layers

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')`

Generating copper layers / pads / drills + ready for FEM workbench

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.

Supply copper thickness per layer, pass a 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.

Generating a single copper layer

pcb.setLayer('F.Cu')
pcb.makeCopper()

Filtering by net name

For local nets you have to specify full hierarchical name

pcb.setNetFilter('GND')
pcb.makeCopper()

pcb.setNetFilter('GND','VCC')
pcb.makeCopper()

Shape without intermediate document objects

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

Screenshots

FEM of tracks and drills

Full Board Loaded in FC for FEM

Full PCB in FreeCAD

Full PCB in FreeCAD

PCB for milling

PCB for milling

FEM of tracks and drills

Full Board Loaded in FC for FEM

Requirements

FreeCAD >= v0.17

More Repositories

1

FreeCAD_assembly3

Experimental attempt for the next generation assembly workbench for FreeCAD
Python
879
star
2

usbip

Fork of usb/ip from linux kernel. Adding support of filters for application layer acceleration.
C
55
star
3

slvs_py

SolveSpace Python binding package source
Shell
29
star
4

kicad_parser

KiCAD parser written in python
Python
15
star
5

FreeCADMakeImage

Scripts for making FreeCAD AppImage and more.
Shell
13
star
6

ld3320

Experiment with LD3320 using teensy 3
C
9
star
7

mac-headers

Collection of private headers for building mac osx or ios projects
C
7
star
8

sexp_parser

Python S-Expression Object Model
Python
6
star
9

a33_linux

Linux kernel 3.4 for Allwinner A33
C
6
star
10

Connectors_Amass.3dshapes

3D models of AMASS connectors for use in KiCad and FreeCAD
5
star
11

a33_android_device_astar

Android device directory for Allwinner A33 (codename astar)
Makefile
5
star
12

a33_lichee_tools

Tools directory from Allwinner A33 SDK
Shell
3
star
13

a33_bootloader

Bootloader source code from Allwinner A33 SDK 4.4
C
3
star
14

Connectors_Molex.3dshapes

3D models of Molex connectors for use in KiCad and FreeCAD
2
star
15

network-cmds-plus

Upgrade of saurik's port of network-cmds for ios with complete ipv6 support, plus radvd and radvdump.
Shell
2
star
16

molexGen

Auto generation of Molex connectors 3d model with color for KiCad and FreeCAD using offical Step files
Python
2
star
17

a33_android_device_common

Android device common directory for Allwinner A33
C
1
star
18

org.freecadweb.FreeCAD.Link.BaseApp

1
star
19

asm3-wiki

FreeCAD Assembly3 documents
1
star
20

py_slvs

Precompiled SolverSpace python bindings
Python
1
star
21

py3_slvs

SolveSpace Python3 binding prebuilt binary
Python
1
star
22

hm_sun7i_android

Headmaster Android 4.2 source for Cubie Einstein SOM (Softwinner A20)
1
star
23

Capacitors_SMD.3dshapes

3D models of SMD capacitors for use by KiCad and FreeCAD
1
star
24

a33_lichee_repo

linux build repo for Allwinner A33
1
star
25

Diodes_SMD.3dshapes

3D models of SMD diodes for use in KiCad and FreeCAD
1
star
26

kicad_modules

An attempt to restructure KiCad modules by integrating 3D models with footprints, and to use FreeCAD as the MCAD
Python
1
star