From 549385a139aa69e4d79858c9b48fc74b1d59f742 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Sun, 24 Sep 2023 19:50:30 -0300 Subject: [PATCH] [3D outputs][Added] Option to disable LCSC 3D model download - `download_lcsc` See #415 --- CHANGELOG.md | 2 ++ docs/samples/generic_plot.kibot.yaml | 25 +++++++++++++++++++ .../configuration/outputs/blender_export.rst | 4 +++ .../configuration/outputs/copy_files.rst | 4 +++ .../configuration/outputs/render_3d.rst | 4 +++ docs/source/configuration/outputs/step.rst | 4 +++ docs/source/configuration/outputs/vrml.rst | 4 +++ kibot/out_base_3d.py | 8 +++++- 8 files changed, 54 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b29b2fe3..c4c36345 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Internal templates: - 3DRender_top, 3DRender_top_straight, 3DRender_bottom and 3DRender_bottom_straight: to generate simple and quick 3D renders. +- 3D outputs: + - `download_lcsc` option to disable LCSC 3D model download (See #415) - BoM: - Support for ${field} expansion. (#471) - LCSC links (SchrodingersGat/KiBoM#190) diff --git a/docs/samples/generic_plot.kibot.yaml b/docs/samples/generic_plot.kibot.yaml index 51e10435..17e9c7a0 100644 --- a/docs/samples/generic_plot.kibot.yaml +++ b/docs/samples/generic_plot.kibot.yaml @@ -180,6 +180,11 @@ outputs: # If you want to cache the downloaded files specify a directory using the # KIBOT_3D_MODELS environment variable download: true + # [boolean=true] In addition to try to download the 3D models from KiCad git also try to get + # them from LCSC database. In order to work you'll need to provide the LCSC + # part number. The field containing the LCSC part number is defined by the + # `field_lcsc_part` global variable + download_lcsc: true # [list(string)=[]] List of components to highlight highlight: [] # [boolean=false] Highlight over the component (not under) @@ -673,6 +678,11 @@ outputs: # If you want to cache the downloaded files specify a directory using the # KIBOT_3D_MODELS environment variable download: true + # [boolean=true] In addition to try to download the 3D models from KiCad git also try to get + # them from LCSC database. In order to work you'll need to provide the LCSC + # part number. The field containing the LCSC part number is defined by the + # `field_lcsc_part` global variable + download_lcsc: true # [list(dict)] Which files will be included files: # [string=''] Destination directory inside the output dir, empty means the same of the file @@ -2956,6 +2966,11 @@ outputs: # If you want to cache the downloaded files specify a directory using the # KIBOT_3D_MODELS environment variable download: true + # [boolean=true] In addition to try to download the 3D models from KiCad git also try to get + # them from LCSC database. In order to work you'll need to provide the LCSC + # part number. The field containing the LCSC part number is defined by the + # `field_lcsc_part` global variable + download_lcsc: true # [number=720] Image height (aprox.) height: 720 # [list(string)=[]] List of components to highlight @@ -3225,6 +3240,11 @@ outputs: # If you want to cache the downloaded files specify a directory using the # KIBOT_3D_MODELS environment variable download: true + # [boolean=true] In addition to try to download the 3D models from KiCad git also try to get + # them from LCSC database. In order to work you'll need to provide the LCSC + # part number. The field containing the LCSC part number is defined by the + # `field_lcsc_part` global variable + download_lcsc: true # [string='https://gitlab.com/kicad/libraries/kicad-packages3D/-/raw/master/'] Base URL for the KiCad 3D models kicad_3d_url: 'https://gitlab.com/kicad/libraries/kicad-packages3D/-/raw/master/' # [string=''] Text added to the end of the download URL. @@ -3453,6 +3473,11 @@ outputs: # If you want to cache the downloaded files specify a directory using the # KIBOT_3D_MODELS environment variable download: true + # [boolean=true] In addition to try to download the 3D models from KiCad git also try to get + # them from LCSC database. In order to work you'll need to provide the LCSC + # part number. The field containing the LCSC part number is defined by the + # `field_lcsc_part` global variable + download_lcsc: true # [list(string)=[]] List of components to highlight highlight: [] # [boolean=false] Highlight over the component (not under) diff --git a/docs/source/configuration/outputs/blender_export.rst b/docs/source/configuration/outputs/blender_export.rst index 095574e5..04da93f7 100644 --- a/docs/source/configuration/outputs/blender_export.rst +++ b/docs/source/configuration/outputs/blender_export.rst @@ -49,6 +49,10 @@ Parameters: - ``dnf_filter`` :index:`: ` [string|list(string)='_none'] Name of the filter to mark components as not fitted. A short-cut to use for simple cases where a variant is an overkill. + - ``download_lcsc`` :index:`: ` [boolean=true] In addition to try to download the 3D models from KiCad git also try to get + them from LCSC database. In order to work you'll need to provide the LCSC + part number. The field containing the LCSC part number is defined by the + `field_lcsc_part` global variable. - ``highlight`` :index:`: ` [list(string)=[]] List of components to highlight. - ``highlight_on_top`` :index:`: ` [boolean=false] Highlight over the component (not under). diff --git a/docs/source/configuration/outputs/copy_files.rst b/docs/source/configuration/outputs/copy_files.rst index debe0344..b2396b02 100644 --- a/docs/source/configuration/outputs/copy_files.rst +++ b/docs/source/configuration/outputs/copy_files.rst @@ -54,6 +54,10 @@ Parameters: - ``dnf_filter`` :index:`: ` [string|list(string)='_none'] Name of the filter to mark components as not fitted. A short-cut to use for simple cases where a variant is an overkill. + - ``download_lcsc`` :index:`: ` [boolean=true] In addition to try to download the 3D models from KiCad git also try to get + them from LCSC database. In order to work you'll need to provide the LCSC + part number. The field containing the LCSC part number is defined by the + `field_lcsc_part` global variable. - ``follow_links`` :index:`: ` [boolean=true] Store the file pointed by symlinks, not the symlink. - ``kicad_3d_url`` :index:`: ` [string='https://gitlab.com/kicad/libraries/kicad-packages3D/-/raw/master/'] Base URL for the KiCad 3D models. - ``kicad_3d_url_suffix`` :index:`: ` [string=''] Text added to the end of the download URL. diff --git a/docs/source/configuration/outputs/render_3d.rst b/docs/source/configuration/outputs/render_3d.rst index fbd3ea37..c1ce22ad 100644 --- a/docs/source/configuration/outputs/render_3d.rst +++ b/docs/source/configuration/outputs/render_3d.rst @@ -58,6 +58,10 @@ Parameters: - ``dnf_filter`` :index:`: ` [string|list(string)='_none'] Name of the filter to mark components as not fitted. A short-cut to use for simple cases where a variant is an overkill. + - ``download_lcsc`` :index:`: ` [boolean=true] In addition to try to download the 3D models from KiCad git also try to get + them from LCSC database. In order to work you'll need to provide the LCSC + part number. The field containing the LCSC part number is defined by the + `field_lcsc_part` global variable. - ``height`` :index:`: ` [number=720] Image height (aprox.). - ``highlight`` :index:`: ` [list(string)=[]] List of components to highlight. diff --git a/docs/source/configuration/outputs/step.rst b/docs/source/configuration/outputs/step.rst index 2d8e7364..5055b3d3 100644 --- a/docs/source/configuration/outputs/step.rst +++ b/docs/source/configuration/outputs/step.rst @@ -38,6 +38,10 @@ Parameters: - ``dnf_filter`` :index:`: ` [string|list(string)='_none'] Name of the filter to mark components as not fitted. A short-cut to use for simple cases where a variant is an overkill. + - ``download_lcsc`` :index:`: ` [boolean=true] In addition to try to download the 3D models from KiCad git also try to get + them from LCSC database. In order to work you'll need to provide the LCSC + part number. The field containing the LCSC part number is defined by the + `field_lcsc_part` global variable. - ``kicad_3d_url`` :index:`: ` [string='https://gitlab.com/kicad/libraries/kicad-packages3D/-/raw/master/'] Base URL for the KiCad 3D models. - ``kicad_3d_url_suffix`` :index:`: ` [string=''] Text added to the end of the download URL. Can be used to pass variables to the GET request, i.e. ?VAR1=VAL1&VAR2=VAL2. diff --git a/docs/source/configuration/outputs/vrml.rst b/docs/source/configuration/outputs/vrml.rst index 5dd74ba7..b15d7dda 100644 --- a/docs/source/configuration/outputs/vrml.rst +++ b/docs/source/configuration/outputs/vrml.rst @@ -41,6 +41,10 @@ Parameters: - ``dnf_filter`` :index:`: ` [string|list(string)='_none'] Name of the filter to mark components as not fitted. A short-cut to use for simple cases where a variant is an overkill. + - ``download_lcsc`` :index:`: ` [boolean=true] In addition to try to download the 3D models from KiCad git also try to get + them from LCSC database. In order to work you'll need to provide the LCSC + part number. The field containing the LCSC part number is defined by the + `field_lcsc_part` global variable. - ``highlight`` :index:`: ` [list(string)=[]] List of components to highlight. - ``highlight_on_top`` :index:`: ` [boolean=false] Highlight over the component (not under). diff --git a/kibot/out_base_3d.py b/kibot/out_base_3d.py index 266091e3..b3a99fe8 100644 --- a/kibot/out_base_3d.py +++ b/kibot/out_base_3d.py @@ -133,6 +133,11 @@ class Base3DOptions(VariantOptions): They are downloaded to a temporal directory and discarded. If you want to cache the downloaded files specify a directory using the KIBOT_3D_MODELS environment variable """ + self.download_lcsc = True + """ In addition to try to download the 3D models from KiCad git also try to get + them from LCSC database. In order to work you'll need to provide the LCSC + part number. The field containing the LCSC part number is defined by the + `field_lcsc_part` global variable """ self.kicad_3d_url = 'https://gitlab.com/kicad/libraries/kicad-packages3D/-/raw/master/' """ Base URL for the KiCad 3D models """ self.kicad_3d_url_suffix = '' @@ -147,6 +152,7 @@ class Base3DOptions(VariantOptions): super().copy_options(ref) self.no_virtual = ref.no_virtual self.download = ref.download + self.download_lcsc = ref.download_lcsc self.kicad_3d_url = ref.kicad_3d_url self.kicad_3d_url_suffix = ref.kicad_3d_url_suffix @@ -494,7 +500,7 @@ class Base3DOptions(VariantOptions): # Missing 3D model if self.download: replace = self.try_download_kicad(m3d.m_Filename, full_name, downloaded, rel_dirs, force_wrl) - if replace is None: + if replace is None and self.download_lcsc: replace = self.try_download_easyeda(m3d.m_Filename, full_name, downloaded, sch_comp, lcsc_field) if replace: replace = self.do_colored_tht_resistor(replace, sch_comp, used_extra)