MCPcopy Create free account
hub / github.com/SLiCAP/SLiCAP_python / KiCADsch2svg

Function KiCADsch2svg

SLiCAP/SLiCAPkicad.py:191–212  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

189 return netlist, subckt, subckt_lib
190
191def 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
214def _kicadNetlist(fileName, cirTitle, language="SLiCAP"):
215 if ini.kicad == "":

Callers 3

_kicadNetlistFunction · 0.85
backAnnotateSchematicFunction · 0.85
SLiCAPkicad.pyFile · 0.85

Calls 2

_crop_svgFunction · 0.90
formatMethod · 0.80

Tested by

no test coverage detected