Moved some repeated code to kiplot.py
This commit is contained in:
parent
4e194306d1
commit
87aa2565d0
|
|
@ -432,6 +432,14 @@ def run_output(out, dont_stop=False):
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
def configure_and_run(tree, out_dir, msg):
|
||||||
|
out = RegOutput.get_class_for(tree['type'])()
|
||||||
|
out.set_tree(tree)
|
||||||
|
config_output(out)
|
||||||
|
logger.debug(' - Creating the PCB3D ...')
|
||||||
|
out.run(out_dir)
|
||||||
|
|
||||||
|
|
||||||
def _generate_outputs(outputs, targets, invert, skip_pre, cli_order, no_priority, dont_stop):
|
def _generate_outputs(outputs, targets, invert, skip_pre, cli_order, no_priority, dont_stop):
|
||||||
logger.debug("Starting outputs for board {}".format(GS.pcb_file))
|
logger.debug("Starting outputs for board {}".format(GS.pcb_file))
|
||||||
# Make a list of target outputs
|
# Make a list of target outputs
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import json
|
||||||
import os
|
import os
|
||||||
from tempfile import NamedTemporaryFile, TemporaryDirectory
|
from tempfile import NamedTemporaryFile, TemporaryDirectory
|
||||||
from .error import KiPlotConfigurationError
|
from .error import KiPlotConfigurationError
|
||||||
from .kiplot import get_output_targets, run_output, run_command, register_xmp_import, config_output
|
from .kiplot import get_output_targets, run_output, run_command, register_xmp_import, config_output, configure_and_run
|
||||||
from .gs import GS
|
from .gs import GS
|
||||||
from .optionable import Optionable
|
from .optionable import Optionable
|
||||||
from .out_base_3d import Base3D, Base3DOptionsWithHL
|
from .out_base_3d import Base3D, Base3DOptionsWithHL
|
||||||
|
|
@ -285,11 +285,7 @@ class Blender_ExportOptions(Optionable):
|
||||||
'layers': ['F.Cu', 'B.Cu', 'F.Paste', 'B.Paste', 'F.Mask', 'B.Mask',
|
'layers': ['F.Cu', 'B.Cu', 'F.Paste', 'B.Paste', 'F.Mask', 'B.Mask',
|
||||||
{'layer': 'F.SilkS', 'suffix': 'F_SilkS'},
|
{'layer': 'F.SilkS', 'suffix': 'F_SilkS'},
|
||||||
{'layer': 'B.SilkS', 'suffix': 'B_SilkS'}]}
|
{'layer': 'B.SilkS', 'suffix': 'B_SilkS'}]}
|
||||||
out = RegOutput.get_class_for(tree['type'])()
|
configure_and_run(tree, out_dir, ' - Creating SVG for layers ...')
|
||||||
out.set_tree(tree)
|
|
||||||
config_output(out)
|
|
||||||
logger.debug(' - Creating SVG for layers ...')
|
|
||||||
out.run(out_dir)
|
|
||||||
|
|
||||||
def create_pads(self, dest_dir):
|
def create_pads(self, dest_dir):
|
||||||
tree = {'name': '_temporal_pcb3d_tools',
|
tree = {'name': '_temporal_pcb3d_tools',
|
||||||
|
|
@ -297,11 +293,7 @@ class Blender_ExportOptions(Optionable):
|
||||||
'comment': 'Internally created for the PCB3D',
|
'comment': 'Internally created for the PCB3D',
|
||||||
'dir': dest_dir,
|
'dir': dest_dir,
|
||||||
'options': {'stackup_create': self.pcb3d.version == '2.1_haschtl'}}
|
'options': {'stackup_create': self.pcb3d.version == '2.1_haschtl'}}
|
||||||
out = RegOutput.get_class_for(tree['type'])()
|
configure_and_run(tree, dest_dir, ' - Creating Pads and boundary ...')
|
||||||
out.set_tree(tree)
|
|
||||||
config_output(out)
|
|
||||||
logger.debug(' - Creating Pads and boundary ...')
|
|
||||||
out.run(dest_dir)
|
|
||||||
|
|
||||||
def create_pcb3d(self, data_dir):
|
def create_pcb3d(self, data_dir):
|
||||||
out_dir = self._parent.output_dir
|
out_dir = self._parent.output_dir
|
||||||
|
|
@ -338,11 +330,7 @@ class Blender_ExportOptions(Optionable):
|
||||||
{'source': os.path.join(data_dir, 'pcb.wrl'),
|
{'source': os.path.join(data_dir, 'pcb.wrl'),
|
||||||
'dest': '/'},
|
'dest': '/'},
|
||||||
]}}
|
]}}
|
||||||
out = RegOutput.get_class_for(tree['type'])()
|
configure_and_run(tree, out_dir, ' - Creating the PCB3D ...')
|
||||||
out.set_tree(tree)
|
|
||||||
config_output(out)
|
|
||||||
logger.debug(' - Creating the PCB3D ...')
|
|
||||||
out.run(out_dir)
|
|
||||||
return out_name
|
return out_name
|
||||||
|
|
||||||
def solve_pcb3d(self):
|
def solve_pcb3d(self):
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2022 Salvador E. Tropea
|
# Copyright (c) 2022-2023 Salvador E. Tropea
|
||||||
# Copyright (c) 2022 Instituto Nacional de Tecnología Industrial
|
# Copyright (c) 2022-2023 Instituto Nacional de Tecnología Industrial
|
||||||
# License: GPL-3.0
|
# License: GPL-3.0
|
||||||
# Project: KiBot (formerly KiPlot)
|
# Project: KiBot (formerly KiPlot)
|
||||||
"""
|
"""
|
||||||
|
|
@ -23,7 +23,7 @@ from tempfile import NamedTemporaryFile, TemporaryDirectory, mkdtemp
|
||||||
from .error import KiPlotConfigurationError
|
from .error import KiPlotConfigurationError
|
||||||
from .misc import PCB_GENERATORS, RENDERERS, W_MORERES
|
from .misc import PCB_GENERATORS, RENDERERS, W_MORERES
|
||||||
from .gs import GS
|
from .gs import GS
|
||||||
from .kiplot import config_output, run_output, get_output_dir, load_board, run_command
|
from .kiplot import config_output, run_output, get_output_dir, load_board, run_command, configure_and_run
|
||||||
from .optionable import BaseOptions, Optionable
|
from .optionable import BaseOptions, Optionable
|
||||||
from .out_base import BaseOutput
|
from .out_base import BaseOutput
|
||||||
from .registrable import RegOutput
|
from .registrable import RegOutput
|
||||||
|
|
@ -145,11 +145,7 @@ class PresentBoards(Optionable):
|
||||||
'type': 'compress',
|
'type': 'compress',
|
||||||
'comment': 'Internally created to compress gerbers',
|
'comment': 'Internally created to compress gerbers',
|
||||||
'options': {'output': tmp_name, 'files': [{'from_output': out.name, 'dest': '/'}]}}
|
'options': {'output': tmp_name, 'files': [{'from_output': out.name, 'dest': '/'}]}}
|
||||||
out = RegOutput.get_class_for('compress')()
|
configure_and_run(tree, os.path.dirname(tmp_name), 'Creating gerbers archive ...')
|
||||||
out.set_tree(tree)
|
|
||||||
config_output(out)
|
|
||||||
logger.debug('Creating gerbers archive ...')
|
|
||||||
out.options.run(tmp_name)
|
|
||||||
|
|
||||||
def generate_archive(self, out, tmp_name):
|
def generate_archive(self, out, tmp_name):
|
||||||
out.options
|
out.options
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue