Skip to content

Commit

Permalink
[3D outputs][Added] Option to disable LCSC 3D model download
Browse files Browse the repository at this point in the history
- `download_lcsc`
 See #415
  • Loading branch information
set-soft committed Sep 24, 2023
1 parent e6a8677 commit 549385a
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
25 changes: 25 additions & 0 deletions docs/samples/generic_plot.kibot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions docs/source/configuration/outputs/blender_export.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ Parameters:
- ``dnf_filter`` :index:`: <pair: output - blender_export - options - pcb3d; dnf_filter>` [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:`: <pair: output - blender_export - options - pcb3d; download_lcsc>` [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:`: <pair: output - blender_export - options - pcb3d; highlight>` [list(string)=[]] List of components to highlight.

- ``highlight_on_top`` :index:`: <pair: output - blender_export - options - pcb3d; highlight_on_top>` [boolean=false] Highlight over the component (not under).
Expand Down
4 changes: 4 additions & 0 deletions docs/source/configuration/outputs/copy_files.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ Parameters:
- ``dnf_filter`` :index:`: <pair: output - copy_files - options; dnf_filter>` [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:`: <pair: output - copy_files - options; download_lcsc>` [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:`: <pair: output - copy_files - options; follow_links>` [boolean=true] Store the file pointed by symlinks, not the symlink.
- ``kicad_3d_url`` :index:`: <pair: output - copy_files - options; kicad_3d_url>` [string='https://gitlab.com/kicad/libraries/kicad-packages3D/-/raw/master/'] Base URL for the KiCad 3D models.
- ``kicad_3d_url_suffix`` :index:`: <pair: output - copy_files - options; kicad_3d_url_suffix>` [string=''] Text added to the end of the download URL.
Expand Down
4 changes: 4 additions & 0 deletions docs/source/configuration/outputs/render_3d.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ Parameters:
- ``dnf_filter`` :index:`: <pair: output - render_3d - options; dnf_filter>` [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:`: <pair: output - render_3d - options; download_lcsc>` [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:`: <pair: output - render_3d - options; height>` [number=720] Image height (aprox.).
- ``highlight`` :index:`: <pair: output - render_3d - options; highlight>` [list(string)=[]] List of components to highlight.

Expand Down
4 changes: 4 additions & 0 deletions docs/source/configuration/outputs/step.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ Parameters:
- ``dnf_filter`` :index:`: <pair: output - step - options; dnf_filter>` [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:`: <pair: output - step - options; download_lcsc>` [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:`: <pair: output - step - options; kicad_3d_url>` [string='https://gitlab.com/kicad/libraries/kicad-packages3D/-/raw/master/'] Base URL for the KiCad 3D models.
- ``kicad_3d_url_suffix`` :index:`: <pair: output - step - options; kicad_3d_url_suffix>` [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.
Expand Down
4 changes: 4 additions & 0 deletions docs/source/configuration/outputs/vrml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ Parameters:
- ``dnf_filter`` :index:`: <pair: output - vrml - options; dnf_filter>` [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:`: <pair: output - vrml - options; download_lcsc>` [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:`: <pair: output - vrml - options; highlight>` [list(string)=[]] List of components to highlight.

- ``highlight_on_top`` :index:`: <pair: output - vrml - options; highlight_on_top>` [boolean=false] Highlight over the component (not under).
Expand Down
8 changes: 7 additions & 1 deletion kibot/out_base_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ def __init__(self):
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 = ''
Expand All @@ -147,6 +152,7 @@ def copy_options(self, ref):
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

Expand Down Expand Up @@ -494,7 +500,7 @@ def download_models(self, rename_filter=None, rename_function=None, rename_data=
# 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)
Expand Down

0 comments on commit 549385a

Please sign in to comment.