I must be misunderstanding something. I really need a sanity check.
I'm trying to duplicate the active object, then delete all the material slots from it without affecting the original.
==== EDIT====== Thanks for the answers, it looks like I only have this problem when the code is part of an operator:
def invoke(self, context, event) :
def deleteMatsFromDuplicate():
scene = context.scene
# Duplicate the model
obj = context.active_object
obj.select = False
obj_copy = obj.copy()
obj_copy.location += Vector((1, 1, 1))
mesh_copy = obj.data.copy()
obj_copy.data = mesh_copy
scene.objects.link(obj_copy)
scene.objects.active = obj_copy
obj_copy.select = True
obj_copy.name = "copy"
#loop thru and remove all
for ms in obj_copy.material_slots:
bpy.ops.object.material_slot_remove()
# end deleteMatsFromDuplicate
deleteMatsFromDuplicate()
return {"FINISHED"}
#end invoke
import bpy
to the start. $\endgroup$ – MattMS Jul 13 '16 at 5:35bpy.ops.some_op('INVOKE_DEFAULT')
See blender.stackexchange.com/a/19431/15543 $\endgroup$ – batFINGER Jul 14 '16 at 5:59