[PcbDraw][Print_PCB] Fixed issues when LXML isn't installed

- Moved PcbDraw import after the tool check
This commit is contained in:
Salvador E. Tropea 2022-10-28 13:03:30 -03:00
parent d3b32a4193
commit 700bf5bff3
2 changed files with 11 additions and 5 deletions

View File

@ -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)

View File

@ -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