blob: c0ce8666ea388dafa92c0f13d60d6503a93373ca (
plain) (
tree)
|
|
#!/bin/bash
#
# This script runs the conversion from Altium to KiCad. It expects the
# Altium project in ../../../hardware/cad/rev03/ and the altium2kicad
# source in ../altium2kicad
#
set -e
export A2K_STARTTIME="1476542686"
altiumdir="rev03-Altium"
kicaddir="rev03-KiCad"
test -d altium2kicad || git clone https://github.com/thesourcerer8/altium2kicad
rm -rf ${altiumdir}
cp -rp ../../../hardware/cad/rev03/ ${altiumdir}
cd ${altiumdir}
# make sheet numbers in filenames two digits to have them sort properly
rename 's/rev02_/rev02_0/' rev02_?.*
../altium2kicad/unpack.pl
../altium2kicad/convertschema.pl
../altium2kicad/convertpcb.pl
cd ..
rm -rf "${kicaddir}"
mkdir "${kicaddir}"
cp ${altiumdir}/*.{sch,lib} "${kicaddir}"/
rm ${kicaddir}/rev02*-cache.lib
cp ${altiumdir}/CrypTech-PcbDoc.kicad_pcb "${kicaddir}/Cryptech Alpha.kicad_pcb"
cp -rp ${altiumdir}/wrlshp ${kicaddir}/wrlshp
cp "Cryptech Alpha.pro.template" "${kicaddir}/Cryptech Alpha.pro"
cp "Cryptech Alpha.sch.template" "${kicaddir}/Cryptech Alpha.sch"
# Fix wrl paths
wrlpath=$(readlink -f ${altiumdir}/wrlshp)
sed -i -e "s!${wrlpath}!wrlshp!g" ${kicaddir}/rev02_*
cd ${kicaddir}
# Change to more sensible filenames
rename 's/-SchDoc//' rev02_*
sed -i -e 's/-SchDoc//g' *.{sch,lib}
# Change some PCB parameters
sed -i -e 's/trace_min 0.254/trace_min 0.15/g' "Cryptech Alpha.kicad_pcb"
# show ratsnest
sed -i -e 's/visible_elements 7FFFF77F/visible_elements 7FFFFF7F/g' "Cryptech Alpha.kicad_pcb"
# Sheet number fixups. This hides all the hierarchical sub-sheets from the project view.
num_sheets=$(ls Cryptech\ Alpha.sch rev02*sch | wc -l)
num=1
ls Cryptech\ Alpha.sch rev02*sch | while read file; do
sed -i -e "s/^Sheet .*/Sheet ${num} ${num_sheets}/g" "${file}"
num=$[$num + 1]
done
echo ""
echo "Done. The leftovers from conversion is in ${altiumdir}, and you can start KiCad like this:"
echo ""
echo " kicad \"${kicaddir}/Cryptech Alpha.pro\""
echo ""
|