From 786c94a80c79de64d335154fe64fc0225cdd3d35 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Tue, 21 Mar 2023 10:40:27 -0300 Subject: [PATCH] [3D] Added option to enable the colored R cache --- CHANGELOG.md | 1 + kibot/globals.py | 3 +++ kibot/gs.py | 1 + kibot/out_base_3d.py | 2 +- 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 511b788c..fdf0b331 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `colored_tht_resistors` to disable the 3D colored resistors. - `field_tolerance` field/s to look for resistor tolerance. - `default_resistor_tolerance` which tolerance to use when none found. + - `cache_3d_resistors` to avoid generating them all the time. - 3D: colored 3D models for THT resistors ### Fixed diff --git a/kibot/globals.py b/kibot/globals.py index 42d9cd50..2d7ad5a1 100644 --- a/kibot/globals.py +++ b/kibot/globals.py @@ -274,6 +274,9 @@ class Globals(FiltersOptions): """ When no tolerance is specified we use this value. Note that I know 5% is a common default, but technically speaking 20% is the default. Used while creating colored resistors """ + self.cache_3d_resistors = False + """ Use a cache for the generated 3D models of colored resistors. + Will save time, but you could need to remove the cache if you need to regenerate them """ self.set_doc('filters', " [list(dict)] KiBot warnings to be ignored ") self._filter_what = 'KiBot warnings' self.filters = FilterOptionsKiBot diff --git a/kibot/gs.py b/kibot/gs.py index 149bada9..a691e521 100644 --- a/kibot/gs.py +++ b/kibot/gs.py @@ -122,6 +122,7 @@ class GS(object): def_global_output = '%f-%i%I%v.%x' # The class that controls the global options class_for_global_opts = None + global_cache_3d_resistors = None global_castellated_pads = None global_colored_tht_resistors = None global_copper_thickness = None diff --git a/kibot/out_base_3d.py b/kibot/out_base_3d.py index 31bf1c85..76066287 100644 --- a/kibot/out_base_3d.py +++ b/kibot/out_base_3d.py @@ -405,7 +405,7 @@ class Base3DOptions(VariantOptions): self.widths = self.widths[:-2] # Create the name in the cache cache_name = self.colored_tht_resistor_name(name, bars) - if os.path.isfile(cache_name): + if os.path.isfile(cache_name) and GS.global_cache_3d_resistors: status = 'cached' else: status = 'created'