Skip to content
This repository has been archived by the owner on Mar 6, 2022. It is now read-only.

Commit

Permalink
fixed some functions and improved docu
Browse files Browse the repository at this point in the history
  • Loading branch information
nerdyscout committed Jun 1, 2020
1 parent 0741b5a commit 83b0ca1
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 38 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
FROM setsoft/kicad_debian as kicad
LABEL MAINTAINER nerdyscout <nerdyscout@posteo.de>
LABEL Description="export various files from KiCad projects"
LABEL VERSION="v0.2"

# update packages
RUN apt-get update
Expand Down Expand Up @@ -34,11 +35,10 @@ RUN cd /opt/kiplot && pip3 install -e .
COPY submodules/kicad-automation-scripts /opt/kicad-automation
RUN pip3 install psutil==5.7.0
RUN pip3 install xvfbwrapper==0.2.9
RUN apt-get install -y xvfb xclip xdotool
RUN apt-get install -y xvfb xclip xdotool xsltproc
RUN cd /opt/kicad-automation && python3 setup.py install
RUN alias pcbnew_do=/opt/kicad-automation/src/pcbnew_do && alias eeschema_do=/opt/kicad-automation/src/eeschema_do


#alias for all commands
COPY functions.sh .
COPY kicad-exports.sh /entrypoint.sh
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ build:
docker build -t kicad-exports .
# echo "$(DOCKER)" > kicad-exports
# chmod +x kicad-exports
cp -u kicad-exports ~/.local/bin/kicad-exports
# cp -u kicad-exports ~/.local/bin/kicad-exports

shell:
$(DOCKER) bash
Expand Down
26 changes: 15 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
This project aims to auto generate several files (gerbers, documentation, pictures, ...) for kicad projects. You could run it locally or on every `git push` with Github actions.
:warning: This project is still in a beta state, please use with care!

# Quick usage
kicad-exports aims to auto generate several files (gerbers, documentation, pictures, ...) for [kicad](kicad-pcb.org/) projects. You could run it locally or on every `git push` with Github Actions.

# tl;dr

```
./kicad-exports $COMMAND $DIR $SCHMATIC $BOARD $PROJECT $MANUFACTURER $PARAMETERS
cd /my/kicad/project
./kicad-exports $COMMAND $DIR_OUT $SCHMATIC_FILE $BOARD_FILE $PROJECT_FILE $MANUFACTURER $PARAMETERS
```

# usage of kicad-exports with Github Actions

run kicad-exports as individual step, as `cmd` several [functions](funtions.sh) are defined.
run kicad-exports as individual step, select `cmd` from list of [functions](functions.sh) according whatever you want to run.

```yaml
name: example
Expand All @@ -28,7 +31,7 @@ on:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: nerdyscout/kicad-exports@master
- uses: nerdyscout/kicad-exports@v0.2
with:
# Required - command to run
cmd: command to run on kicad files
Expand All @@ -51,12 +54,14 @@ on:
path: example
```
For examples of more full workflows see [kicad-exports-test](https://github.com/nerdyscout/kicad-exports-test/tree/master/.github/workflows).
For examples of more full workflows see [kicad-exports-test](https://github.com/nerdyscout/kicad-exports-test/blob/v0.2/.github/workflows).
# use kicad-exports local
## Installation
You need to have [Docker](https://www.docker.com/) installed.
```
git clone github.com/nerdyscout/kicad-exports /some/where/kicad-exports
cd /some/where/kicad-exports
Expand All @@ -68,14 +73,14 @@ make build
go to your KiCad project folder and run kicad-exports.sh
```
cd /my/kicad/project
./some/where/kicad-exports/kicad-exports.sh *$COMMAND*
./some/where/kicad-exports/kicad-exports.sh $COMMAND
```
*$COMMAND* can be anything running within the container, e.g.
$COMMAND can be anything running within the container, e.g.
```
./some/where/kicad-exports/kicad-exports.sh "eeschema_do export -f pdf $SCHEMATIC $DIR"
./some/where/kicad-exports/kicad-exports.sh kicad-schematic-pdf
```
both lines do the same as there are several aliases defined, checkout the [functions.sh](functions.sh)
Both lines produce the same output as there are several aliases defined, checkout the [functions.sh](functions.sh). kicad-exports tries to guess your schematic file, board file etc. but if they are in a subfolder you have to set it manually.

# Credits
- [Kiplot](https://github.com/INTI-CMNB/kiplot)
Expand All @@ -85,5 +90,4 @@ both lines do the same as there are several aliases defined, checkout the [funct
- [PCBDraw](https://github.com/yaqwsx/PcbDraw)
- [Tracespace](https://github.com/tracespace/tracespace/tree/master/packages/cli)
- [IBoM](https://github.com/openscopeproject/InteractiveHtmlBom/wiki/Usage)
- https://github.com/obra/
- https://github.com/INTI-CMNB/
- [kicad-tools](https://github.com/obra/kicad-tools)
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ inputs:
required: false
runs:
using: 'docker'
image: docker://nerdyscout/kicad-exports:latest
image: docker://nerdyscout/kicad-exports:v0.2
args:
- ${{ inputs.cmd }}
- ${{ inputs.dir }}
Expand Down
73 changes: 51 additions & 22 deletions functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

function schematic() {
kicad-schematic
mv $DIR/$NAME.pdf $DIR/$NAME"_schematic.pdf"
mv $DIR/$NAME.pdf $DIR/$NAME"_schematic.svg"
}

function report() {
Expand All @@ -15,6 +17,19 @@ function fabrication() {
kiplot-drills
}

#function mechanics() {
# kiplot -b $BOARD -c /opt/kiplot/documentation.yaml -d /tmp
# kiplot -b $BOARD -c /opt/kiplot/drills.yaml -d /tmp
# tracespace -L /tmp/*Edge_Cuts.gbr /tmp/*PTH-drl.gbr /tmp/*Dwgs*.gbr
#}

#function documentation() {
# schematic
# kiplot-documentation
# #TODO: run something to generate shiny svg from /tmp/$NAME*.gbr
# #eg board measurments, pinouts from comment layer etc
#}

function kicad-schematic() {
kicad-schematic-svg
kicad-schematic-pdf
Expand All @@ -32,10 +47,18 @@ function kicad-netlist() {
eeschema_do $VERBOSE netlist $SCHEMATIC $DIR
}

function erc() {
kicad-erc
}

function kicad-erc() {
eeschema_do $VERBOSE run_erc $SCHEMATIC $DIR
}

function drc() {
kicad-drc
}

function kicad-drc() {
pcbnew_do $VERBOSE run_drc $BOARD $DIR
}
Expand All @@ -46,44 +69,50 @@ function bom() {
kicost
}

#TODO: this one still fails
# dont get confused... this actually outputs a CSV
function kicad-bom() {
eeschema_do $VERBOSE bom_xml $SCHEMATIC $DIR
rm $DIR/$NAME.xml
}

#TODO: define more sets with various layers
function kicad-board() {
pcbnew_do $VERBOSE export $BOARD $DIR Dwgs.User Cmts.User
}

#TODO: this one still fails
function kibom() {
eeschema_do $VERBOSE bom_xml $SCHEMATIC /tmp
python3 -m kibom $VERBOSE -d $DIR /tmp/$NAME.xml --cfg /opt/kibom/bom.ini $DIR/$PROJECT.xlsx
python3 -m kibom $VERBOSE -d $DIR $NAME.xml --cfg /opt/kibom/bom.ini $DIR/$NAME.xlsx
rm $DIR/$NAME.xml
}

function ibom() {
sh /opt/ibom/ibom.sh $BOARD $DIR
}

#FIXME
function kicost() {
python3 -m kicost -i $DIR/$NAME.xml -o $DIR/$NAME.xlsx --include digikey farnell
eeschema_do $VERBOSE bom_xml $SCHEMATIC $DIR
python3 -m kicost -i $DIR/$NAME.xml -o $DIR/$NAME.xlsx $PARAMETERS
rm $DIR/$NAME.xml
}

function gerbers() {
kiplot-gerber
}

function kiplot-documentation() {
kiplot -b $BOARD -c /opt/kiplot/documentation.yaml $VERBOSE -d $DIR
}

function kiplot-gerber() {
kiplot -b $BOARD -c /opt/kiplot/gerbers.yaml $VERBOSE -d $DIR
}

function kiplot-position() {
kiplot -b $BOARD -c /opt/kiplot/position.yaml $VERBOSE -d $DIR
if [ "$MANUFACTURER" = "jlcpcb" ]; then
sed s/'Ref,Val,Package,PosX,PosY,Rot,Side'/'Designator,Value,Package,Mid X,Mid Y,Rotation,Layer'/g $DIR/*pos.csv
sed -i s/'Ref,Val,Package,PosX,PosY,Rot,Side'/'Designator,Value,Package,Mid X,Mid Y,Rotation,Layer'/g $DIR/*pos.csv
fi
# define other manufacturers
}

function kiplot-drills() {
Expand All @@ -109,44 +138,44 @@ function pcbdraw-bottom() {
# fi
}

#fails because of "swig/python detected a memory leak of type 'DLIST_ITERATOR_WRAPPER< D_PAD > *', no destructor found."
function pcbdraw-bare() {
pcbdraw-bare-front
pcbdraw-bare-bottom
}

function pcbdraw-bare-front() {

# if [ "$MANUFACTURER" = "oshpark" ]; then
# TODO:
# generate purple pcb
# else
if [ "$MANUFACTURER" = "oshpark" ]; then
# FIXME: might fail as i dont know wher the styles are located
pcbdraw --filter "" --style oshpark-purple.json $BOARD $DIR/$NAME"_bare_front.png"
else
pcbdraw --filter "" $BOARD $DIR/$NAME"_bare_front.png"
# fi
fi
}

function pcbdraw-bare-bottom() {
# if [ "$MANUFACTURER" = "oshpark" ]; then
# TODO:
# generate purple pcb
# else
if [ "$MANUFACTURER" = "oshpark" ]; then
# FIXME: might fail as i dont know wher the styles are located
pcbdraw --filter "" --style oshpark-purple.json -b $BOARD $DIR/$NAME"_bare_bottom.png"
else
pcbdraw --filter "" -b $BOARD $DIR/$NAME"_bare_bottom.png"
# fi
fi
}

function tracespace-board() {
kiplot -b $BOARD -c /opt/kiplot/gerbers.yaml $VERBOSE -d /tmp
kiplot -b $BOARD -c /opt/kiplot/drills.yaml $VERBOSE -d /tmp
tracespace -L /tmp/*Edge_Cuts.gbr /tmp/*.drl /tmp/*Mask.gbr /tmp/*SilkS.gbr /tmp/*Cu.gbr
mv $NAME*top*.svg $DIR/$NAME"_Top_Board.svg"
mv $NAME*bottom*.svg $DIR/$NAME"_Bottom_Board.svg"
mv $NAME*top*.svg $DIR/$NAME"_Board_Top.svg"
mv $NAME*bottom*.svg $DIR/$NAME"_Board_Bottom.svg"
}

function tracespace-assembly() {
kiplot -b $BOARD -c /opt/kiplot/gerbers.yaml $VERBOSE -d /tmp
kiplot -b $BOARD -c /opt/kiplot/drills.yaml $VERBOSE -d /tmp
tracespace -B /tmp/*Fab.gbr
mv $NAME*B_Fab*.svg $DIR/$NAME"_Bottom_Assembly.svg"
mv $NAME*F_Fab*.svg $DIR/$NAME"_Top_Assembly.svg"
mv $NAME*B_Fab*.svg $DIR/$NAME"_Assembly_Bottom.svg"
mv $NAME*F_Fab*.svg $DIR/$NAME"_Assembly_Top.svg"
}

function kikit-panelize() {
Expand Down
1 change: 0 additions & 1 deletion kicad-exports

This file was deleted.

61 changes: 61 additions & 0 deletions opt/kiplot/documentation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# https://github.com/INTI-CMNB/kiplot

kiplot:
version: 1

preflight:
run_erc: false
update_xml: false
run_drc: false
check_zone_fills: true
ignore_unconnected: true

outputs:
- name: "documentation"
comment: "documentation layers from PCB"
type: "gerber"
dir: ""
options:
# generic layer options
exclude_edge_layer: false
exclude_pads_from_silkscreen: false
use_aux_axis_as_origin: false
plot_sheet_reference: true
plot_footprint_refs: true
plot_footprint_values: true
force_plot_invisible_refs_vals: false
tent_vias: true
check_zone_fills: true

# gerber options
line_width: 0.15
subtract_mask_from_silk: true
use_protel_extensions: false
gerber_precision: 4.5
create_gerber_job_file: false
use_gerber_x2_attributes: true
use_gerber_net_attributes: false

layers:
- layer: F.SilkS
suffix: F_SilkS
- layer: F.Fab
suffix: F_Fab
- layer: B.SilkS
suffix: B_SilkS
- layer: B.Fab
suffix: B_Fab
- layer: Edge.Cuts
suffix: Edge_Cuts
- layer: Cmts.User
suffix: Cmts_User
- layer: Dwgs.User
suffix: Dwgs_User
- layer: Eco1.User
suffix: Eco1_User
- layer: Eco2.User
suffix: Eco2_User
- layer: F.CrtYd
suffix: F_CrtYd
- layer: B.CrtYd
suffix: B_CrtYd

0 comments on commit 83b0ca1

Please sign in to comment.