Skip to content

Commit

Permalink
Added better error handling when material slots are empty
Browse files Browse the repository at this point in the history
  • Loading branch information
cmbasnett committed Sep 20, 2024
1 parent 37c255f commit 6380422
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions io_scene_ase/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def get_unique_materials(mesh_objects: Iterable[Object]) -> List[Material]:
for i, material_slot in enumerate(mesh_object.material_slots):
material = material_slot.material
if material is None:
raise RuntimeError('Material slot cannot be empty (index ' + str(i) + ')')
raise RuntimeError(f'Material slots cannot be empty ({mesh_object.name}, material slot index {i})')
materials.add(material)
return list(materials)

Expand Down Expand Up @@ -308,7 +308,12 @@ def invoke(self, context: 'Context', event: 'Event' ) -> Union[Set[str], Set[int
mesh_objects = [x[0] for x in get_mesh_objects(context.selected_objects)]

pg = getattr(context.scene, 'ase_export')
populate_material_list(mesh_objects, pg.material_list)

try:
populate_material_list(mesh_objects, pg.material_list)
except RuntimeError as e:
self.report({'ERROR'}, str(e))
return {'CANCELLED'}

self.filepath = f'{context.active_object.name}.ase'

Expand Down

0 comments on commit 6380422

Please sign in to comment.