Creates drawing-size images in .SVG and .PDF format from KiCad schematics. The image files will be placed in the img subdirectory in the project fodler. The names of the image files equal that of the schematic file, but the file extensions differ (.svg and .pdf). :param fi
(fileName)
| 189 | return netlist, subckt, subckt_lib |
| 190 | |
| 191 | def KiCADsch2svg(fileName): |
| 192 | """ |
| 193 | Creates drawing-size images in .SVG and .PDF format from KiCad schematics. |
| 194 | The image files will be placed in the img subdirectory in the project fodler. |
| 195 | The names of the image files equal that of the schematic file, but the |
| 196 | file extensions differ (.svg and .pdf). |
| 197 | |
| 198 | :param fileName: Name of the KiCad schematic file, relative to project |
| 199 | folder or absolute |
| 200 | :type fileName: str |
| 201 | """ |
| 202 | if ini.kicad == "": |
| 203 | print("Please install KiCad, delete '~/SLiCAP.ini', and run this script again.") |
| 204 | else: |
| 205 | cirName = fileName.split('/')[-1].split('.')[0] |
| 206 | if os.path.isfile(fileName): |
| 207 | print("Creating drawing-size SVG and PDF images of {}".format(fileName)) |
| 208 | subprocess.run([ini.kicad, 'sch', 'export', 'svg', '-o', ini.img_path, '-e', '-n', fileName]) |
| 209 | _crop_svg(ini.img_path + cirName + ".svg") |
| 210 | renderPDF.drawToFile(svg2rlg(ini.img_path + cirName + ".svg"), ini.img_path + cirName + ".pdf") |
| 211 | else: |
| 212 | print("Error: could not open: '{}'.".format(fileName)) |
| 213 | |
| 214 | def _kicadNetlist(fileName, cirTitle, language="SLiCAP"): |
| 215 | if ini.kicad == "": |
no test coverage detected