prman-pixar / RenderManForBlender

RenderMan for Blender render addon
MIT License
808 stars 134 forks source link

When starting IPR: "IndexError: bpy_prop_collection[index]: index 27800 out of range, size 2" #692

Closed erjiang closed 1 year ago

erjiang commented 1 year ago

I have a scene where the following error appears when trying to start IPR:

Array iterator out of range: Mesh_materials_lookup_int (index 24280)
[ERROR] (MainThread) RenderManForBlender.rfb_logger start_interactive_render: Export Failed:
Traceback (most recent call last):
  File "/home/eric/.config/blender/3.6/scripts/addons/RenderManForBlender/rman_render.py", line 1086, in start_interactive_render
    self.rman_scene.export_for_interactive_render(context, depsgraph, self.sg_scene)
  File "/home/eric/.config/blender/3.6/scripts/addons/RenderManForBlender/rman_scene.py", line 255, in export_for_interactive_render
    self.export()
  File "/home/eric/.config/blender/3.6/scripts/addons/RenderManForBlender/rman_scene.py", line 319, in export
    self.export_data_blocks()
  File "/home/eric/.config/blender/3.6/scripts/addons/RenderManForBlender/rman_scene.py", line 717, in export_data_blocks
    rman_sg_node = self.get_rman_prototype(proto_key, ob=ob_eval, create=True)
  File "/home/eric/.config/blender/3.6/scripts/addons/RenderManForBlender/rman_scene.py", line 976, in get_rman_prototype
    rman_sg_node = self.export_data_block(proto_key, ob)
  File "/home/eric/.config/blender/3.6/scripts/addons/RenderManForBlender/rman_scene.py", line 784, in export_data_block
    translator.update(ob, rman_sg_node)
  File "/home/eric/.config/blender/3.6/scripts/addons/RenderManForBlender/rman_translators/rman_mesh_translator.py", line 476, in update
    mat = ob.data.materials[mat_id]
IndexError: bpy_prop_collection[index]: index 24280 out of range, size 2

However, regular rendering (F8) works without error. I'd prefer not to share the scene here but I can send it to someone directly.

I am temporarily working around this error with this:

--- rman_mesh_translator.py.orig    2023-10-13 15:36:19.526489671 -0700
+++ rman_mesh_translator.py 2023-10-13 15:39:14.361880151 -0700
@@ -473,7 +473,12 @@
             for mat_id, faces in \
                 _get_mats_faces_(nverts, material_ids).items():

+                try:
                 mat = ob.data.materials[mat_id]
+                except IndexError:
+                    mat = None
+                    print("Could not get material at index %d for object %s" % (mat_id, ob.name))
+
                 if not mat:
                     continue
                 sg_material = self.rman_scene.rman_materials.get(mat.original, None)

Linux, Blender 3.6.4, RfB 25.2.0

prman-pixar commented 1 year ago

@erjiang

Yes, I would need to see the scene. I can send you a link to a BOX folder for you to copy the file, but I would need your e-mail address.

erjiang commented 1 year ago

@erjiang

Yes, I would need to see the scene. I can send you a link to a BOX folder for you to copy the file, but I would need your e-mail address.

Please use the address on my Github profile. Thanks!

prman-pixar commented 1 year ago

PR merged in. Closing.