Skip to content

Instantly share code, notes, and snippets.

@m4rk3r
Last active August 29, 2015 14:23
Show Gist options
  • Save m4rk3r/5c4a463f68ab5d98c749 to your computer and use it in GitHub Desktop.
Save m4rk3r/5c4a463f68ab5d98c749 to your computer and use it in GitHub Desktop.
Batch blender
from os import mkdir
from os.path import exists, join
from subprocess import Popen
#blender = 'c:\Program Files\Blender Foundation\Blender\Blender.exe'
blender = '/Applications/Blender/blender.app/Contents/MacOS/blender'
# filepath = 'c:\Users\studio\Dropbox\files\'
filepath = '/Users/mark/Dropbox/files/'
# output = 'c:\Users\studio\Dropbox\results\batch\'
output = '/Users/mark/Dropbox/results/batch/'
files = [
'handle-a.blend',
'handle-b.blend',
'handle-c.blend',
]
def setup(config, index):
config.update({
'blender':blender,
'filepath':filepath,
'output': output,
'dir':'render-part-%s' % index,
'target': 'Scene'
})
outputpath = join(config['output'],config['dir'])
if not exists(outputpath):
mkdir(outputpath)
config['outputpath'] = outputpath
return config
jobs = [
{'file':files[0], 'start':2000, 'end':2002, },
{'file':files[1], 'start':2000, 'end':2002, },
{'file':files[0], 'start':4000, 'end':4002, },
{'file':files[1], 'start':4000, 'end':4002, }
]
cmd = '{blender} -b {filepath}{file} -x 1 -o {outputpath}/ -F PNG -s {start} -e {end} -S {target} -a'
idx = 0
for job in jobs:
p = Popen( cmd.format(**setup(job, idx)).split(' ') )
p.wait()
idx += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment