Ghostkeeper / Blender3mfFormat

Blender add-on to import/export 3MF files
GNU General Public License v2.0
173 stars 20 forks source link

AttributeError: 'NoneType' object has no attribute 'name' when object has blank Material #47

Open ansonl opened 1 year ago

ansonl commented 1 year ago

Hi, sometimes when I try to export objects, I get the below exception.

Traceback (most recent call last):
  File "C:\Users\ansonl\AppData\Roaming\Blender Foundation\Blender\2.90\scripts\addons\io_mesh_3mf\export_3mf.py", line 116, in execute
    self.material_name_to_index = self.write_materials(resources_element, blender_objects)
  File "C:\Users\ansonl\AppData\Roaming\Blender Foundation\Blender\2.90\scripts\addons\io_mesh_3mf\export_3mf.py", line 221, in write_materials
    material_name = material.name
AttributeError: 'NoneType' object has no attribute 'name'

location: <unknown location>:-1

It happens when one of the objects had a Material created and assigned to it and then the material was deleted in the material menu with the X button next the material.

image

This leaves a blank material entry in the materials list for the object. This seems to be fixed by deleting the empty material with the "-" button in the list, but it would be nice if the 3MF addon did not error on this.

I tried importing the current master branch of the addon into Blender with the same error results.