plot schematic as svg
This commit is contained in:
parent
7dc94bf7be
commit
976e91cda7
|
|
@ -22,6 +22,7 @@ CORRUPTED_PCB = 17
|
|||
KICAD2STEP_ERR = 18
|
||||
WONT_OVERWRITE = 19
|
||||
PCBDRAW_ERR = 20
|
||||
SVG_SCH_PRINT = 21
|
||||
|
||||
CMD_EESCHEMA_DO = 'eeschema_do'
|
||||
URL_EESCHEMA_DO = 'https://github.com/INTI-CMNB/kicad-automation-scripts'
|
||||
|
|
|
|||
|
|
@ -0,0 +1,50 @@
|
|||
import os
|
||||
from subprocess import (call)
|
||||
from .gs import (GS)
|
||||
from .kiplot import (check_eeschema_do)
|
||||
from .misc import (CMD_EESCHEMA_DO, SVG_SCH_PRINT)
|
||||
from .optionable import BaseOptions
|
||||
from kiplot.macros import macros, document, output_class # noqa: F401
|
||||
from . import log
|
||||
|
||||
logger = log.get_logger(__name__)
|
||||
|
||||
|
||||
class SVG_Sch_PrintOptions(BaseOptions):
|
||||
def __init__(self):
|
||||
with document:
|
||||
self.output = GS.def_global_output
|
||||
""" filename for the output SVG (%i=schematic %x=svg) """ # pragma: no cover
|
||||
super().__init__()
|
||||
|
||||
def run(self, output_dir, board):
|
||||
check_eeschema_do()
|
||||
cmd = [CMD_EESCHEMA_DO, 'export', '--all_pages', '--file_format', 'svg', GS.sch_file, output_dir]
|
||||
if GS.debug_enabled:
|
||||
cmd.insert(1, '-vv')
|
||||
cmd.insert(1, '-r')
|
||||
logger.debug('Executing: '+str(cmd))
|
||||
ret = call(cmd)
|
||||
if ret:
|
||||
logger.error(CMD_EESCHEMA_DO+' returned %d', ret)
|
||||
exit(SVG_SCH_PRINT)
|
||||
if self.output:
|
||||
id = 'schematic'
|
||||
ext = 'svg'
|
||||
cur = self.expand_filename_sch(output_dir, '%f.%x', id, ext)
|
||||
new = self.expand_filename_sch(output_dir, self.output, id, ext)
|
||||
logger.debug('Moving '+cur+' -> '+new)
|
||||
os.rename(cur, new)
|
||||
|
||||
|
||||
@output_class
|
||||
class SVG_Sch_Print(BaseOutput): # noqa: F821
|
||||
""" SVG Schematic Print
|
||||
Exports the PCB. Suitable for printing.
|
||||
This a format to document your schematic. """
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
with document:
|
||||
self.options = SVG_Sch_PrintOptions
|
||||
""" [dict] Options for the `svg_sch_print` output """ # pragma: no cover
|
||||
self._sch_related = True
|
||||
Loading…
Reference in New Issue