Align Objects fails with IndexError: bpy_prop_collection[-1]: out of range.
Closed, ResolvedPublic

Description

System Information
OS: Arch Linux
GPU: 01:00.0 VGA compatible controller: NVIDIA Corporation GM206 [GeForce GTX 950] (rev a1)

Blender Version
Broken:

  • Stable release: 2.79 8ef39d5c882
  • builder build: 2.79 f6107af4cf4

Worked:

  • No idea

Short description of error

Align Objects fails with:

Traceback (most recent call last):
  File "/usr/share/blender/2.79/scripts/startup/bl_operators/object_align.py", line 409, in execute
    self.bb_quality,
  File "/usr/share/blender/2.79/scripts/startup/bl_operators/object_align.py", line 152, in align_objects
    GBB = GlobalBB_HQ(obj)
  File "/usr/share/blender/2.79/scripts/startup/bl_operators/object_align.py", line 77, in GlobalBB_HQ
    val = matrix_world * verts[-1].co
IndexError: bpy_prop_collection[-1]: out of range.

Exact steps for others to reproduce the error

  1. Download my .blend.
  2. The cubes are already selected. Do Spacebar -> Align Objects
  3. Python IndexError

Additional notes
I encountered this bug by chance. I don't know what the simplest reproducer would be. Two notable features of my .blend reproducer are:

  • I'm using multiple instances of the same linked object, a cube.
  • There are two materials on different surfaces of the cube.
  • *EDIT* apparently I also have some overlapping objects/edges/surfaces.

This may or may not be relevant. I haven't found a less complex reproducer.

You've got a bunch of objects using mesh data Cube which doesn't have any vertices, the operator uses the vertices to find out where it should align (or something like that) so it fails when there are no vertices. If you isolate the objects that actually are the cubes (using mesh data Cube.001) it works fine. Did you mean to have empty mesh objects instead of using for example Empties?

Hi Henrik, thanks for the very fast response.

Did you mean to

I'm generally not quite sure what I meant to do cause I'm a noob. Please bear with me!

In this case I meant to select only the cubes with mesh data Cube.001.
I guess it makes sense that you can't align an empty object with no vertices.
Looking at the Outliner I still can't spot what is selected aside from the cubes. :S

Hi Henrik, thanks for the very fast response.

Did you mean to

I'm generally not quite sure what I meant to do cause I'm a noob. Please bear with me!

In this case I meant to select only the cubes with mesh data Cube.001.
I guess it makes sense that you can't align an empty object with no vertices.
Looking at the Outliner I still can't spot what is selected aside from the cubes. :S

You can deselect all objects and then run this (copy into the text editor and click Run Script):

import bpy

for obj in bpy.data.objects:
    if obj.data.name == "Cube":
        obj.select = True

All of the objects with the Cube mesh data (that has no vertices) will be selected, you can move them to another layer or delete them if you don't actually need them. Right now they don't really do anything from what I can see anyway. After doing that and only selecting the cubes that are left you should be able to align them.

Ok. I see what's happening now. I also learned how to use the text editor today. 👍

As I said, I'm very new to blender and I just saw "python exception" and my python instincts said I should open a bug report. If this sort of exception is considered trivial or low priority please feel free to close this task. I'll be more careful what I select in the future.

Ok. I see what's happening now. I also learned how to use the text editor today. 👍

As I said, I'm very new to blender and I just saw "python exception" and my python instincts said I should open a bug report. If this sort of exception is considered trivial or low priority please feel free to close this task. I'll be more careful what I select in the future.

You can report it here if it's a script/addon bundled with Blender meaning it's in the Blender software folder\2.79\scripts folder, if it's a user addon (AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons) you will have to tell the person that actually made that addon. In your case I think it's a bug with this particular script though.

You could also try googling the exception error and see what it means if you're interested in python scripting, maybe you can fix it yourself. In this particular case it's not that easy though.