Skip to content

Commit 8a8d628

Browse files
authored
Merge pull request #857 from matthijskooijman/colored-resistors-use-wrl
[3D][Fixed]: Do not fail resistor coloring when model is not wrl
2 parents 1fd8c16 + a5bc8e3 commit 8a8d628

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

kibot/out_base_3d.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from .EasyEDA.easyeda_3d import download_easyeda_3d_model
1515
from .fil_base import reset_filters
1616
from .misc import (W_MISS3D, W_FAILDL, W_DOWN3D, DISABLE_3D_MODEL_TEXT, W_BADTOL, W_BADRES, W_RESVALISSUE, W_RES3DNAME,
17-
EMBED_PREFIX, get_file_hash)
17+
W_MISSWRL, EMBED_PREFIX, get_file_hash)
1818
from .gs import GS
1919
from .optionable import Optionable
2020
from .out_base import VariantOptions, BaseOutput
@@ -371,6 +371,17 @@ def create_colored_tht_resistor(self, ori, name, bars, r_len):
371371
def do_colored_tht_resistor(self, name, c, changed):
372372
if not GS.global_colored_tht_resistors or not self.is_tht_resistor(name) or c is None:
373373
return name
374+
375+
base, ext = os.path.splitext(name)
376+
if ext != '.wrl':
377+
wrl_version = base + '.wrl'
378+
if os.path.isfile(wrl_version):
379+
logger.debug('Using WRL version for {} for generating resistor colors'.format(c.ref))
380+
name = wrl_version
381+
else:
382+
logger.warning(W_MISSWRL+'Missing WRL 3D model for resistor colors: `{}`'.format(name))
383+
return name
384+
374385
# Find the length of the resistor (is in the name of the 3D model)
375386
m = re.search(r"L([\d\.]+)mm", name)
376387
if not m:

0 commit comments

Comments
 (0)