[VRML][Fixed] Problems with missing 3D models and targets

This commit is contained in:
Salvador E. Tropea 2023-01-17 20:35:21 -03:00
parent 96daf7e4a8
commit 2f2ac6f8ae
2 changed files with 11 additions and 6 deletions

View File

@ -192,7 +192,7 @@ class Base3DOptions(VariantOptions):
logger.warning(W_DOWN3D+' {} 3D models downloaded'.format(len(downloaded)))
return models_replaced if not is_copy_mode else list(source_models)
def list_models(self):
def list_models(self, even_missing=False):
""" Get the list of 3D models """
# Load KiCad configuration so we can expand the 3D models path
KiConf.init(GS.pcb_file)
@ -202,7 +202,7 @@ class Base3DOptions(VariantOptions):
# Look for all the 3D models for this footprint
for m3d in m.Models():
full_name = KiConf.expand_env(m3d.m_Filename)
if os.path.isfile(full_name):
if even_missing or os.path.isfile(full_name):
models.add(full_name)
return list(models)

View File

@ -51,10 +51,15 @@ class VRMLOptions(Base3DOptions):
def get_targets(self, out_dir):
targets = [self._parent.expand_filename(out_dir, self.output)]
if self.dir_models:
# We will also generate the models
dir = os.path.join(out_dir, self.dir_models)
filtered = {os.path.join(dir, os.path.basename(replace_ext(m, 'wrl'))) for m in self.list_models()}
targets.extend(list(filtered))
# Missing models can be downloaded during the 3D variant filtering
# Also renamed or disabled.
# # We will also generate the models
# dir = os.path.join(out_dir, self.dir_models)
# filtered = {os.path.join(dir, os.path.basename(replace_ext(m, 'wrl')))
# for m in self.list_models(even_missing=True)}
# targets.extend(list(filtered))
# So we just add the dir
targets.append(os.path.join(out_dir, self.dir_models))
return targets
def get_pcb_center(self):