I have a strange situation. As part of a larger project, I need to copy an object and mesh, and apply all modifiers on the copy except Armature modifiers. Below is a little chunk of code that should do this, but keeps crashing Blender:
import bpy Object = bpy.data.objects["Cube"] Object2 = Object.copy() Mesh = Object.data.copy() Object2.data = Mesh bpy.context.scene.objects.link(Object2) bpy.context.scene.objects.active = Object2 for Modifier in [Modifier for Modifier in Object2.modifiers if Modifier.type != "ARMATURE"]: print("Crash happens after this...") bpy.ops.object.modifier_apply(apply_as="DATA", modifier=Modifier.name) print("And before this...") bpy.context.scene.objects.unlink(Object2) bpy.data.objects.remove(Object2) bpy.data.meshes.remove(Mesh)
The thing I don’t understand is, when I follow these same steps in a console window, they work as expected.
Here’s a link to a little test file I setup. Open it up and just click Run Script to test it.
I’m using Blender 2.52 r30120 with 32-bit Windows XP.
If anyone has any insight as to why this is happening, or any ways to get around it, please let me know.
Edit: Just tested r30230, which is the most recent at this writing. Same problem.