Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# this script will scan the following specified folder for collada files, change it to wherever you are storing them
YourFolderPath = ''
# i.e. YourFolderPath = 'C:\\Users\\Martin\\Desktop'
# The .dae files in that folder will be iteratively imported into blender and rendered
# The images will be output to whatever folder path is specified in the output field within Blender
# They will be organised in folders, where each folder has the same name as the .dae file which was rendered
# If you wish, you can uncomment the following line and replace the output path with your own manually.
# bpy.context.scene.render.filepath = 'your output folder path here'
# Blender will freeze whilst it is rendering, it's automated so that shouldn't be an issue.
# if you want to check it is working, then check the output folder as it works.
# set up the scene to render as normal, including output resolution, samples, number of frames etc...
# to see the scripts text output as it runs:
# go to Window -> Toggle System Console
# this is useful to track the script as it goes
# built using Blender 2.81
import bpy
import os
outputPath = bpy.context.scene.render.filepath
def scanFolder(inputPath):
objList = []
for file in os.listdir(inputPath):
if file.endswith(".dae"):
objList.append(os.path.join(inputPath, file))
print("found:" + file)
return objList
def LoadOBJ(filePath):
imported_object = bpy.context.active_object
mat ="Head")
# Assign it to object
if[0] = mat
return imported_object;
def SetOutput(filePath):
name = bpy.path.display_name(filePath) + '\\'
bpy.context.scene.render.filepath = os.path.join(outputPath, name)
def ResetOutput():
bpy.context.scene.render.filepath = outputPath
def DoRender():
if not( os.path.exists(YourFolderPath) and os.path.isdir(YourFolderPath) ):
YourFolderPath = os.path.dirname(
for daePath in scanFolder(YourFolderPath):
# check collada path
if not( os.path.exists(daePath) ):
print("invalid collada directory")
# move to sub directory of output folder
# make output folder
except OSError:
print("unable to create folder, it may already exist")
# check output folder
if not( os.path.exists(bpy.context.scene.render.filepath) and os.path.isdir(bpy.context.scene.render.filepath) ):
print("invalid output directory")
# load object
LoadOBJ(daePath) # sets active object to imported
# will block for duration of render
# delete
bpy.ops.object.delete() # deletes active object
# reset to base output folder
print("Complete :)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment