Skip to content

Commit 350c413

Browse files
committed
Make the plugin a bit more tolerant to failures.
1 parent 220e274 commit 350c413

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

io_scene_pyrogenesis/__init__.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
bl_info = {
2222
'name': 'Blender Pyrogenesis Importer',
2323
'author': 'Stanislas Daniel Claude Dolcini',
24-
'version': (1, 3, 5),
24+
'version': (1, 3, 6),
2525
'blender': (2, 80, 0),
2626
'location': 'File > Import-Export',
2727
'description': 'Import ',
@@ -445,9 +445,13 @@ def parse_actor(self, root, proppoint="root", parentprops=[], rootObj=None, prop
445445
# Import the new objects
446446
if child.tag == "mesh":
447447
mesh_path = self.currentPath + 'meshes/' + child.text
448-
fixer = MaxColladaFixer(mesh_path)
449-
fixer.execute()
450-
bpy.ops.wm.collada_import(filepath=mesh_path, import_units=True)
448+
try:
449+
450+
fixer = MaxColladaFixer(mesh_path)
451+
fixer.execute()
452+
bpy.ops.wm.collada_import(filepath=mesh_path, import_units=True)
453+
except:
454+
print('Could not load' + mesh_path)
451455
else:
452456
bpy.ops.object.select_all(action='DESELECT')
453457
if material_type == 'default.xml' or 'terrain' in material_type:
@@ -595,16 +599,21 @@ def parse_actor(self, root, proppoint="root", parentprops=[], rootObj=None, prop
595599
print("============== Gathering Props ========================")
596600
print("=======================================================")
597601
if prop.attrib['actor'] is "":
598-
continue;
602+
continue
599603

600-
print('Loading ' + self.currentPath + 'actors/' + prop.attrib['actor'] + '.')
601-
proproot = ET.parse(self.currentPath + 'actors/' + prop.attrib['actor']).getroot()
604+
try:
605+
prop_path = self.currentPath + 'actors/' + prop.attrib['actor']
606+
print('Loading ' + prop_path + '.')
607+
proproot = ET.parse(prop_path).getroot()
602608

603-
propRootObj = self.find_prop_root_object(finalprops, prop.attrib['attachpoint'])
604-
if propRootObj is not None and prop.attrib['attachpoint'] is not 'root' and rootObject is None:
605-
rootObject = propRootObj
609+
propRootObj = self.find_prop_root_object(finalprops, prop.attrib['attachpoint'])
610+
if propRootObj is not None and prop.attrib['attachpoint'] is not 'root' and rootObject is None:
611+
rootObject = propRootObj
612+
613+
self.parse_actor(proproot, prop.attrib['attachpoint'], meshprops if finalprops is None or len(finalprops) <= 0 else finalprops, rootObject, propDepth + 1)
614+
except:
615+
print('Could not load' + mesh_path)
606616

607-
self.parse_actor(proproot, prop.attrib['attachpoint'], meshprops if finalprops is None or len(finalprops) <= 0 else finalprops, rootObject, propDepth + 1)
608617

609618
def find_prop_root_object(self, imported_objects, proppoint):
610619
for imported_object in imported_objects:
@@ -641,7 +650,7 @@ def __init__(self, file_path=None):
641650
def execute(self):
642651
import xml.etree.ElementTree as ET
643652
from datetime import date
644-
653+
645654
tree = ET.parse(self.file_path)
646655
ET.register_namespace("", "http://www.collada.org/2005/11/COLLADASchema")
647656
root = tree.getroot()

0 commit comments

Comments
 (0)