-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathgenerate_landscapes.py
31 lines (23 loc) · 1.04 KB
/
generate_landscapes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python3
import subprocess
from os.path import dirname, abspath, join
directory = dirname(abspath(__file__))
# the blueprint file contains some custom gras models which are randomly
# chosen and placed in the scene
blueprintPath = join(directory, "blueprint.blend")
scriptPath = join(directory, "landscape.py")
# we want to constantly print the output from our script
# source: https://stackoverflow.com/a/4417735/13440564
def execute(cmd):
popen = subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True)
for stdout_line in iter(popen.stdout.readline, ""):
yield stdout_line
popen.stdout.close()
return_code = popen.wait()
if return_code:
raise subprocess.CalledProcessError(return_code, cmd)
for i in range(3):
print("Generating scene %d..." % (i+1))
#print(subprocess.check_output(['blender', blueprintPath, '--background', '--python', scriptPath]).decode())
for path in execute(['blender', blueprintPath, '--background', '--python', scriptPath]):
print(path, end="")