diff --git a/kibot/out_pcb_print.py b/kibot/out_pcb_print.py index 0703433c..900ade28 100644 --- a/kibot/out_pcb_print.py +++ b/kibot/out_pcb_print.py @@ -51,8 +51,6 @@ from .create_pdf import create_pdf_from_pages from .macros import macros, document, output_class # noqa: F401 from .drill_marks import DRILL_MARKS_MAP, add_drill_marks from .layer import Layer, get_priority -from .PcbDraw.plot import PcbPlotter, PlotSubstrate -from .PcbDraw.convert import save from . import __version__ from . import log @@ -771,6 +769,9 @@ class PCB_PrintOptions(VariantOptions): self.plot_vias(la, pc, p, filelist, VIATYPE_MICROVIA, self.micro_via_color) def pcbdraw_by_module(self, pcbdraw_file, back): + self.ensure_tool('LXML') + from .PcbDraw.plot import PcbPlotter, PlotSubstrate + from .PcbDraw.convert import save # Run PcbDraw to make the heavy work (find the Edge.Cuts path and create masks) try: plotter = PcbPlotter(GS.board) diff --git a/kibot/out_pcbdraw.py b/kibot/out_pcbdraw.py index 065de0bd..a44b86f4 100644 --- a/kibot/out_pcbdraw.py +++ b/kibot/out_pcbdraw.py @@ -31,14 +31,15 @@ from .optionable import Optionable from .out_base import VariantOptions from .macros import macros, document, output_class # noqa: F401 from . import log -from .PcbDraw.plot import (PcbPlotter, PlotPaste, PlotPlaceholders, PlotSubstrate, PlotVCuts, mm2ki, PlotComponents, - ResistorValue) -from .PcbDraw.convert import save logger = log.get_logger() +def mm2ki(val: float) -> int: + return int(val * 1000000) + + def pcbdraw_warnings(tag, msg): logger.warning('{}({}) {}'.format(W_PCBDRAW, tag, msg)) @@ -336,6 +337,7 @@ class PcbDrawOptions(VariantOptions): return [self._parent.expand_filename(out_dir, self.output)] def build_plot_components(self): + from .PcbDraw.plot import PlotComponents, ResistorValue remapping = self._remap def remapping_fun(ref, lib, name): @@ -395,6 +397,9 @@ class PcbDrawOptions(VariantOptions): def run(self, name): super().run(name) + self.ensure_tool('LXML') + from .PcbDraw.plot import PcbPlotter, PlotPaste, PlotPlaceholders, PlotSubstrate, PlotVCuts + from .PcbDraw.convert import save # Select a name and format that PcbDraw can handle save_output_name = name save_output_format = self.format