enable background and remove timer in autobuild

1.2.0

- changed: enabled when launched in background
- added: autobuild: hide "invisible" material
- removed: timer to setup render scene
This commit is contained in:
pullusb
2023-01-17 15:50:10 +01:00
parent 0eea0661bc
commit 544cd7bf56
6 changed files with 116 additions and 176 deletions
+37 -3
View File
@@ -214,8 +214,18 @@ def get_render_scene():
if render_scn:
return render_scn
## -- Create render scene
current = bpy.context.scene
## With data
render_scn = bpy.data.scenes.new('Render')
## With ops (goes directly into scene)
# bpy.ops.scene.new(type='NEW')
# render_scn = bpy.context.scene
# print('render_scn: ', render_scn)
# render_scn.name = 'Render'
## copy original settings over to new scene
# copy_settings(current, render_scn) # BAD
for attr in ['frame_start', 'frame_end', 'frame_current', 'camera', 'world']:
@@ -223,7 +233,7 @@ def get_render_scene():
copy_settings(current.render, render_scn.render)
## link cameras (and lights ?)
for ob in bpy.context.scene.objects:
for ob in current.objects:
if ob.type in ('CAMERA', 'LIGHT'):
render_scn.collection.objects.link(ob)
@@ -235,7 +245,7 @@ def get_render_scene():
# render_scn.node_tree.nodes.remove(n)
set_settings(render_scn)
render_scn['use_aa'] = True
render_scn['use_aa'] = True
return render_scn
def get_view_layer(name, scene=None):
@@ -253,6 +263,24 @@ def get_view_layer(name, scene=None):
pass_vl.use_pass_z = True
return pass_vl
def set_resolution_from_cam_prop(cam=None, scene=None):
if scene is None:
scene = bpy.context.scene
if not cam:
cam = scene.camera
if not cam:
return ('ERROR', 'No active camera')
res = cam.get('resolution')
if not res:
return ('ERROR', 'Cam has no resolution attribute')
rd = scene.render
if rd.resolution_x == res[0] and rd.resolution_y == res[1]:
return ('INFO', f'Resolution already at {res[0]}x{res[1]}')
else:
rd.resolution_x, rd.resolution_y = res[0], res[1]
return ('INFO', f'Resolution to {res[0]}x{res[1]}')
## -- node location tweaks
@@ -487,7 +515,13 @@ def rearrange_rlayers_in_frames(node_tree):
for rl in rlayers:
# move to top with equal size
rl.location.y = top
top -= rl.dimensions.y + 20 # place next down by height + gap of 20
if rl.dimensions.y == 0:
# Newly created nodes
top -= 180 + 20 # down by probable size + gap of 20
else:
top -= rl.dimensions.y + 20 # place next down by height + gap of 20
def rearrange_frames(node_tree):
frame_d = get_frames_bbox(node_tree) # dic : {frame_node:(loc vector, dimensions vector), ...}