Apply modifiers

So I can’t figure out a way to apply the mod I just created… Blender docs are so complicated I don’t understand anything about bpy. I’ve been trying methods for days but nothing works and blender crashes…
Hope someone can tell me how this works

print("\n\n----Executing massive bool----\n\n\n\n")
import bpy

selected = bpy.context.selected_objects.copy()
objtoremove = bpy.context.selected_objects.copy()
length = len(selected)
length = length - 1
print("len: " + str(length))
for i in range(0, length):
    ob = selected[i]
    obj = selected[i + 1]
    ob.select_set(True) = ob
    currname = "boolean_" + str(i)
    bool_mod =, 'BOOLEAN')
    bool_mod.operation = "UNION"
    bool_mod.object = obj
    lastobj = ob
    bpy.ops.object.delete(use_global=False, confirm=False)

What is it, exactly, that you’re trying to do? From the code as presented, it looks like you’re trying to Boolean together some selected objects. Problem is, this will happen in random order. Blender isn’t keeping track of which order the objects were selected in.

It’s crashing though because you didn’t deselect the objects, so when you do the bpy.ops.object.delete, everything selected is getting deleted and you end up with dangling references in your list, attempting to access objects through them -> crash.

I was trying to make some kind of massive boolean script but I’m quite new so I don’t really know how to do it… I’m pretty sure its following an order, the order of the list though.

You misunderstand. That list is not ordered in any particular way. Blender is not keeping track of selection order, other than to know which object is active. See e.g.

Anyway, without a more clear understanding what you’re trying to do it’d be hard to help you.

If, for example, you want to boolean union together all selected objects, then, in order to get reliable results, you’d need to pick one of them (i.e. first), and union all the others with it. If you just walk the list like you do, even assuming you’d fix the crash, you’ll be getting unpredictable results.

uuh, good idea! Thanks