Fix for material slots
authorEugenio Pignataro <info@oscurart.com.ar>
Sat, 24 Jan 2015 20:09:20 +0000 (17:09 -0300)
committerEugenio Pignataro <info@oscurart.com.ar>
Sat, 24 Jan 2015 20:09:20 +0000 (17:09 -0300)
oscurart_tools/oscurart_overrides.py
oscurart_tools/oscurart_render.py

index 8f71ddb..7aa3f5c 100644 (file)
@@ -25,10 +25,12 @@ def DefOscApplyOverrides(self):
     proptolist = list(eval(scene.overrides))   
     for group, material in proptolist:
         for object in bpy.data.groups[group].objects:
+            lenslots = len(object.material_slots)
             if object.type in types:
                 if len(object.data.materials):
                     object.data.materials.clear()
-                    object.data.materials.append(bpy.data.materials[material])                 
+                    for newslot in range(lenslots):                    
+                        object.data.materials.append(bpy.data.materials[material])                 
  
 def DefOscRestoreOverrides(self):
     types = {'MESH','META','CURVE'}
index f34cb41..557441d 100644 (file)
@@ -39,10 +39,12 @@ def defRenderAll (frametype, scenes):
             
         for group, material in proptolist:
             for object in bpy.data.groups[group].objects:
+                lenslots = len(object.material_slots)
                 if object.type in types:
                     if len(object.data.materials):
                         object.data.materials.clear()
-                        object.data.materials.append(bpy.data.materials[material])            
+                        for newslot in range(lenslots):
+                            object.data.materials.append(bpy.data.materials[material])            
         filename = os.path.basename(bpy.data.filepath.rpartition(".")[0])  
         uselayers = {layer : layer.use for layer in scene.render.layers} 
         for layer, usado in uselayers.items():