forked from ldo/render-useful
-
Notifications
You must be signed in to change notification settings - Fork 0
/
render-info
executable file
·93 lines (89 loc) · 2.38 KB
/
render-info
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
#+
# This script displays information about a specified .blend file,
# namely the scenes, render settings and cameras. Invoke it as
# follows:
#
# render-info [options...] blendfile
#
# where the only option is
#
# --blender=blender
# specifies the path to the Blender executable. Defaults to
# searching for the name “blender” in your PATH.
#
# Copyright 2013-2015 by Lawrence D'Oliveiro <[email protected]>.
# Licensed under CC-BY-SA <http://creativecommons.org/licenses/by-sa/4.0/>.
#-
blender=blender
for ((;;)); do
if [ "${1:0:2}" != "--" ]; then
break
fi
opt="${1:2:${#1}}"
shift
val="${opt#*=}"
opt="${opt%%=*}"
if [ "$opt" = "blender" ]; then
blender="$val"
else
echo "$0: bad option $opt" 1>&2
exit 3
fi
done
if [ -z "$(type -p "$blender")" ]; then
echo "$0: no such executable “$blender”" 1>&2
exit 3
fi
if [ $# != 1 ]; then
echo $'Usage:\n\t'"$0" $'<blendfile>\n' 1>&2
exit 3
fi
blendfile="$1"
exec "$blender" 5>&1 1>/dev/null -b "$blendfile" -P <(cat <<'EOD'
import sys
import os
import bpy
out = os.fdopen(5, "w")
# use a different fd from stdout, only way it seems to avoid
# output being polluted by Blender’s messages
active_marker = "→"
other_marker = "*"
for scene in bpy.data.scenes :
out.write \
(
"%s scene “%s”, engine “%s”\n"
%
(
(other_marker, active_marker)[scene.name == bpy.context.scene.name],
scene.name,
scene.render.engine,
)
)
out.write \
(
" frames = %d to %d by %d\n" % (scene.frame_start, scene.frame_end, scene.frame_step)
)
out.write \
(
" render resolution = %d%% × (%d, %d)\n"
%
(scene.render.resolution_percentage, scene.render.resolution_x, scene.render.resolution_y)
)
nr_cameras = 0
for object in scene.objects :
if object.type == "CAMERA" :
nr_cameras += 1
out.write \
(
" %s camera “%s”\n"
%
((other_marker, active_marker)[object.name == scene.camera.name], object.name)
)
#end if
#end for
out.write(" Cameras: %d\n" % nr_cameras)
#end for
out.write("Scenes: %d\n" % len(bpy.data.scenes))
EOD
)