forked from yuki-koyama/blender-cli-rendering
-
Notifications
You must be signed in to change notification settings - Fork 0
/
01_cube.py
33 lines (22 loc) · 897 Bytes
/
01_cube.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
32
33
# blender --background --python 01_cube.py --render-frame 1 -- </path/to/output/image> <resolution_percentage>
import bpy
import os
import sys
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
import utils
def get_output_file_path() -> str:
return str(sys.argv[sys.argv.index('--') + 1])
def get_resolution_percentage() -> int:
return int(sys.argv[sys.argv.index('--') + 2])
def get_num_samples() -> int:
return int(sys.argv[sys.argv.index('--') + 3])
if __name__ == "__main__":
# Args
output_file_path = get_output_file_path()
resolution_percentage = get_resolution_percentage()
num_samples = get_num_samples()
# Setting
scene = bpy.context.scene
camera_object = bpy.data.objects["Camera"]
utils.set_output_properties(scene, resolution_percentage, output_file_path)
utils.set_cycles_renderer(scene, camera_object, num_samples)