Last active
December 14, 2020 10:21
-
-
Save CGLion/bfd23dd532e3875dbd1119d8f049b151 to your computer and use it in GitHub Desktop.
Python for Blender - performs a batch render of all materials with specified name prefix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
fileMaterials = bpy.data.materials | |
print(len(fileMaterials)) | |
renderMaterials = [] | |
for material in fileMaterials: | |
if material.name[:4] == 'mtl_': | |
renderMaterials.append(material) | |
print('Added: '.format(material.name)) | |
scene = bpy.context.scene | |
renderFolder = scene.render.filepath | |
obj = bpy.context.active_object | |
for material in renderMaterials: | |
obj.data.materials[0] = material | |
print('Mat: '.format(material.name)) | |
scene.render.filepath = renderFolder + (material.name) + '.' | |
bpy.ops.render.render(animation = False,write_still = True) | |
scene.render.filepath = renderFolder |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment