Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bpy
- obj = bpy.context.scene.objects.active # Active Object
- mat_names = ["Material.001", "Material", "Material.002"] # names of the materials
- mats = []
- folder = "C:\test\test" # folder to save the different images in: Remember the double bar (\)!
- bf_area_type = bpy.context.area.type
- for m in mat_names:
- mats.extend([bpy.data.materials[m]]) #adding the materials based on their names
- for i, mat in enumerate(mats):
- #if the object has not material slot, it adds one slot to it.
- if obj.data.materials:
- obj.data.materials[0] = mat
- else:
- obj.data.materials.append(mat)
- #render
- bpy.ops.render.render()
- #change the area type to Image editor
- bpy.context.area.type = "IMAGE_EDITOR"
- #Save the image
- bpy.ops.image.save_as(save_as_render=True, copy=True, filepath=folder+"//Render{}.png".format(i), relative_path=False, show_multiview=False, use_multiview=False)
- #Reset the area type
- bpy.context.area.type = bf_area_type
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement