niftools / blender_niftools_addon

The Blender Niftools Addon is a Blender add-on to enable import and export of NetImmese File Formats including .nif, .kf, .egm.
http://www.niftools.org
Other
386 stars 104 forks source link

"TypeError: bpy_struct: item.attr = val: enum "1" not found in ()" with original Oblivion .NIF file #547

Closed Allofich closed 1 year ago

Allofich commented 1 year ago

Issue Overview

An error appears during import of an original Oblivion .NIF file.

Version Information

Blender Niftools Addon Version Info

Built the addon using the following: Python 3.11 New Pyffi: https://github.com/Candoran2/new-pyffi/commit/c8508fe316aa2e978e7677308f06f1b6a2ff48e4 New nif xml: https://github.com/niftools/nifxml/commit/89d03ffe69254ef4b3b58b0a22ec2ff9820b2e63 Latest blender addon code at: https://github.com/Candoran2/blender_nif_plugin/commit/f3898fe667b214367569c5be761bbcf49b527eea (code up for PR in https://github.com/niftools/blender_niftools_addon/pull/541)

Blender Version Info

3.4

Platform information

Windows 11 22H2

Steps to Reproduce

[Ordered list of the steps required for recreating the issue, including settings]

  1. Build the latest blender_niftools_addon using the code versions listed above.
  2. Import meshes/architecture/anvil/anvilaltar01.nif from the Oblivion DVD installation into Blender. This file can be obtained by extracting it from data/Oblivion - Meshes.bsa with a BSA extracting program.
  3. An error (see below) appears in the console.

    Expected Result

    No errors when importing a valid .NIF file.

Actual Result

Error happens.

Console Output

Traceback (most recent call last):
  File "****\AppData\Roaming\Blender Foundation\Blender\3.4\scripts\addons\io_scene_niftools\operators\nif_import_op.py", line 134, in execute
    return NifImport(self, context).execute()
  File "****\AppData\Roaming\Blender Foundation\Blender\3.4\scripts\addons\io_scene_niftools\nif_import.py", line 131, in execute
    self.import_root(root)
  File "****\AppData\Roaming\Blender Foundation\Blender\3.4\scripts\addons\io_scene_niftools\nif_import.py", line 159, in import_root
    b_obj = self.import_branch(root_block)
  File "****\AppData\Roaming\Blender Foundation\Blender\3.4\scripts\addons\io_scene_niftools\nif_import.py", line 240, in import_branch
    b_children.extend(self.import_collision(n_block))
  File "****\AppData\Roaming\Blender Foundation\Blender\3.4\scripts\addons\io_scene_niftools\nif_import.py", line 184, in import_collision
    return self.bhkhelper.import_bhk_shape(n_node.collision_object.body)
  File "****\AppData\Roaming\Blender Foundation\Blender\3.4\scripts\addons\io_scene_niftools\modules\nif_import\collision\havok.py", line 94, in import_bhk_shape
    return self.process_bhk(bhk_shape)
  File "****\Blender 3.4\3.4\python\lib\functools.py", line 889, in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
  File "****\AppData\Roaming\Blender Foundation\Blender\3.4\scripts\addons\io_scene_niftools\modules\nif_import\collision\havok.py", line 170, in import_bhk_rigidbody_t
    self._import_bhk_rigid_body(bhk_shape, collision_objs)
  File "****\AppData\Roaming\Blender Foundation\Blender\3.4\scripts\addons\io_scene_niftools\modules\nif_import\collision\havok.py", line 216, in _import_bhk_rigid_body
    b_col_obj.nifcollision.collision_layer = str(body_info.havok_filter.layer.value)
TypeError: bpy_struct: item.attr = val: enum "1" not found in ()

This warning only appears when importing the anvilaltar01.nif from the DVD installation. It does not happen with the version of this file found in the GOG/Steam versions.

Nif File

See https://github.com/niftools/blender_niftools_addon/issues/546.

Allofich commented 1 year ago

As you mentioned in the other issue, this error doesn't happen when using the nif.xml in https://github.com/Candoran2/nifxml/tree/mickeychanges, as the .nif is assigned the game "Oblivion" instead of "UNKNOWN". I didn't ever see the .nif being detected as "Oblivion KF" by the import plugin, so I don't understand why the above commit for the "Oblivion KF" type is supposed to fix this issue. If it's correct that a "Oblivion KF" file can use collision layers, then all is well I guess, but if that change was supposed to fix the TypeError: bpy_struct: item.attr = val: enum "1" not found in () error for this .nif, I don't see the connection on my end.

I'm assuming the https://github.com/Candoran2/nifxml/tree/mickeychanges nif.xml is the best one to use for testing, since it seems to be the most up-to-date now, so I'll use it from now on. By the way, I consider this issue to be closed because of the changes in that nif.xml file, but I'll wait a while before closing in case you have a comment.

Candoran2 commented 1 year ago

It's essentially a safeguard just in case a (Oblivion) kf file uses collision layers, yeah.

Allofich commented 1 year ago

OK, just letting you know that the "Fix for niftools#547" commit wasn't actually a fix for this issue (for me at least), as it was fixed by the new nif.xml and wasn't detected as "Oblivion KF" for me, anyway. Maybe you were thinking of the ladder .nif in https://github.com/niftools/blender_niftools_addon/issues/546? That one was detected as "Oblivion KF".

Edit: Or the 7 was just a typo, maybe you meant to type "Fix for niftools#546?" That would explain it.

Allofich commented 1 year ago

Well, the ladder .nif wrong detection in #546 is also fixed by the new nif.xml, not the safeguard... Whatever, if it's a good change, that's fine, I just wanted to let you know I couldn't confirm it as fixing any of the issues I created. So if it was a change you otherwise wouldn't have wanted to make, but you made it to fix an issue I created, I think you can remove it. But if it's good to have regardless, than never mind.