Poikilos / io_import_x

Import/export .x files in Blender 3.0 (and some earlier versions). The *Poikilos fork* attempts to maintain compatibility with the latest stable Blender and allows install via GUI (Click "Code", "Download ZIP"--See "Install" in readme for the rest of the steps). Related project (also recently updated): https://github.com/ldo/blender-addons-orphaned
GNU General Public License v3.0
32 stars 9 forks source link

AttributeError: 'Material' object has no attribute 'use_transparency' #4

Closed Poikilos closed 2 years ago

Poikilos commented 2 years ago

Importing a certain x file (that doesn't have alpha, apparently) raises an exception and the model import fails.

importing horse_model.x...
WARNING: There are 1 facemats but 82 faces.The faces length will be used and facemats[0] will be used for each.
Traceback (most recent call last):
  File "/home/owner/.config/blender/2.83/scripts/addons/io_import_x/__init__.py", line 237, in execute
    return import_x.load(self, context, **keywords)
  File "/home/owner/.config/blender/2.83/scripts/addons/io_import_x/import_x.py", line 1090, in load
    import_dXtree(rootTokens, item_file.name)
  File "/home/owner/.config/blender/2.83/scripts/addons/io_import_x/import_x.py", line 731, in import_dXtree
    child = import_dXtree(getChilds(tokenname), file_+"_"+tokenname, lvl=lvl+1)
  File "/home/owner/.config/blender/2.83/scripts/addons/io_import_x/import_x.py", line 731, in import_dXtree
    child = import_dXtree(getChilds(tokenname), file_+"_"+tokenname, lvl=lvl+1)
  File "/home/owner/.config/blender/2.83/scripts/addons/io_import_x/import_x.py", line 731, in import_dXtree
    child = import_dXtree(getChilds(tokenname), file_+"_"+tokenname, lvl=lvl+1)
  File "/home/owner/.config/blender/2.83/scripts/addons/io_import_x/import_x.py", line 678, in import_dXtree
    ob = getMesh(parentname, tokenname)
  File "/home/owner/.config/blender/2.83/scripts/addons/io_import_x/import_x.py", line 904, in getMesh
    mat.use_transparency = True
AttributeError: 'Material' object has no attribute 'use_transparency'
Poikilos commented 2 years ago

"Whether to use alpha is controlled by the Blend Method. As a replacement for reading material.use_transparency, try using material.blend_method != 'OPAQUE'." -scurest Sep 20 '20 at 6:33 on blender.stackexchange.com

Poikilos commented 2 years ago

Blender 2.8 changelog

Material in current API documentation

https://docs.blender.org/api/current/bpy.types.Material.html