From d88830948f1a18a48c8979fe582a718bc16a0146 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Thu, 16 Mar 2023 09:26:54 -0300 Subject: [PATCH] [DOCs] Blender export needs KiCad 6 or newer - Also checks in the code --- README.md | 2 ++ docs/samples/generic_plot.kibot.yaml | 2 ++ kibot/out_blender_export.py | 7 ++++++- kibot/out_pcb2blender_tools.py | 6 +++++- setup.cfg | 2 +- 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8c23b61f..b547d9db 100644 --- a/README.md +++ b/README.md @@ -1572,6 +1572,7 @@ Notes: * Type: `blender_export` * Description: Exports the PCB in various 3D file formats. Also renders the PCB with high-quality. + Needs KiCad 6 or newer. This output is complex to setup and needs very big dependencies. Please be patient when using it. You need Blender with the pcb2blender plug-in installed. @@ -3361,6 +3362,7 @@ Notes: * Type: `pcb2blender_tools` * Description: A bunch of tools used to generate PCB3D files used to export PCBs to Blender. Blender is the most important free software 3D render package. + This output needs KiCad 6 or newer. The PCB3D file format is used by the PCB2Blender project (https://github.com/30350n/pcb2blender) to import KiCad PCBs in Blender. You need to install a Blender plug-in to load PCB3D files. diff --git a/docs/samples/generic_plot.kibot.yaml b/docs/samples/generic_plot.kibot.yaml index 36412cbb..d304d1bc 100644 --- a/docs/samples/generic_plot.kibot.yaml +++ b/docs/samples/generic_plot.kibot.yaml @@ -94,6 +94,7 @@ preflight: outputs: # Blender Export **Experimental**: # Also renders the PCB with high-quality. + # Needs KiCad 6 or newer. # This output is complex to setup and needs very big dependencies. # Please be patient when using it. # You need Blender with the pcb2blender plug-in installed. @@ -2055,6 +2056,7 @@ outputs: variant: '' # PCB2Blender Tools: # Blender is the most important free software 3D render package. + # This output needs KiCad 6 or newer. # The PCB3D file format is used by the PCB2Blender project (https://github.com/30350n/pcb2blender) # to import KiCad PCBs in Blender. # You need to install a Blender plug-in to load PCB3D files. diff --git a/kibot/out_blender_export.py b/kibot/out_blender_export.py index 65d519ed..212e6fce 100644 --- a/kibot/out_blender_export.py +++ b/kibot/out_blender_export.py @@ -17,6 +17,7 @@ from tempfile import NamedTemporaryFile, TemporaryDirectory from .error import KiPlotConfigurationError from .kiplot import get_output_targets, run_output, run_command, register_xmp_import, config_output, configure_and_run from .gs import GS +from .misc import MISSING_TOOL from .optionable import Optionable, BaseOptions from .out_base_3d import Base3D, Base3DOptionsWithHL from .registrable import RegOutput @@ -470,6 +471,9 @@ class Blender_ExportOptions(BaseOptions): return pcb3d_file def run(self, output): + if GS.ki5: + logger.error("`blender_export` needs KiCad 6+") + exit(MISSING_TOOL) pcb3d_file = self.solve_pcb3d() # If no outputs specified just finish # Can be used to export the PCB to Blender @@ -563,6 +567,7 @@ class Blender_Export(Base3D): """ Blender Export **Experimental** Exports the PCB in various 3D file formats. Also renders the PCB with high-quality. + Needs KiCad 6 or newer. This output is complex to setup and needs very big dependencies. Please be patient when using it. You need Blender with the pcb2blender plug-in installed. @@ -605,7 +610,7 @@ class Blender_Export(Base3D): @staticmethod def get_conf_examples(name, layers, templates): - if not GS.check_tool(name, 'Blender'): + if not GS.check_tool(name, 'Blender') or GS.ki5: return None has_top = False has_bottom = False diff --git a/kibot/out_pcb2blender_tools.py b/kibot/out_pcb2blender_tools.py index 50f598a7..a0f0f81b 100644 --- a/kibot/out_pcb2blender_tools.py +++ b/kibot/out_pcb2blender_tools.py @@ -13,7 +13,7 @@ from typing import List from pcbnew import B_Paste, F_Paste, PCB_TEXT_T, ToMM from .gs import GS from .misc import (MOD_THROUGH_HOLE, MOD_SMD, UI_VIRTUAL, W_UNKPCB3DTXT, W_NOPCB3DBR, W_NOPCB3DTL, W_BADPCB3DTXT, - W_UNKPCB3DNAME, W_BADPCB3DSTK) + W_UNKPCB3DNAME, W_BADPCB3DSTK, MISSING_TOOL) from .optionable import Optionable from .out_base import VariantOptions from .macros import macros, document, output_class # noqa: F401 @@ -261,6 +261,9 @@ class PCB2Blender_ToolsOptions(VariantOptions): def run(self, output): super().run(output) + if GS.ki5: + logger.error("`pcb2blender_tools` needs KiCad 6+") + exit(MISSING_TOOL) dir_name = os.path.dirname(output) self.apply_show_components() self.filter_pcb_components(do_3D=True) @@ -302,6 +305,7 @@ class PCB2Blender_Tools(BaseOutput): # noqa: F821 """ PCB2Blender Tools A bunch of tools used to generate PCB3D files used to export PCBs to Blender. Blender is the most important free software 3D render package. + This output needs KiCad 6 or newer. The PCB3D file format is used by the PCB2Blender project (https://github.com/30350n/pcb2blender) to import KiCad PCBs in Blender. You need to install a Blender plug-in to load PCB3D files. diff --git a/setup.cfg b/setup.cfg index c03234ab..15b7139a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -34,7 +34,7 @@ ignore = E402, E226, E126, W504 # docstrings - text style (imperative, dot) D4 max-line-length = 127 -max-complexity = 24 +max-complexity = 30 exclude = experiments/kicad/v6/ experiments/JLC/ experiments/resistor_colors/