autobuild beta max

main
pullusb 2023-01-06 16:05:09 +01:00
parent a736eec7c9
commit dd57f0651e
2 changed files with 19 additions and 33 deletions

View File

@ -63,7 +63,7 @@ class GPEXP_OT_render_auto_build(bpy.types.Operator):
def execute(self, context): def execute(self, context):
print('-- Auto-build Render scene --\n') print('-- Auto-build Render scene --\n')
## TODO: add colors to layers (specified in ENV or hardcoded for now...) ## TODO: Add colors to layers (specified in ENV or hardcoded for now...)
## Option: Maybe find a way to create a color from prefix hash ? (always give unique color with same prefix on other project!) ## Option: Maybe find a way to create a color from prefix hash ? (always give unique color with same prefix on other project!)
render_scn = bpy.data.scenes.get('Render') render_scn = bpy.data.scenes.get('Render')
@ -103,8 +103,21 @@ class GPEXP_OT_render_auto_build(bpy.types.Operator):
if not render_scn: if not render_scn:
self.report({'ERROR'}, 'No render scene found') self.report({'ERROR'}, 'No render scene found')
return {'CANCELLED'} return {'CANCELLED'}
context.window.scene = render_scn context.window.scene = render_scn
## Group all adjacent layer type
print('Group all adjacent layer type')
for ob in ob_list:
fn.group_adjacent_layer_prefix_rlayer(ob, excluded_prefix=['GP', 'PO', 'RG'], first_name=True)
bpy.ops.gp_export.render_scene_setup() # next render scene setup at once
## attempt to refresh scene
# render_scn.node_tree.nodes.update()
# context.view_layer.update()
# context.scene.update_tag()
## Change to GP workspace (if needed) ## Change to GP workspace (if needed)
if context.window.workspace.name != 'GP Render': if context.window.workspace.name != 'GP Render':
print('Change to GP workspace') print('Change to GP workspace')
@ -121,41 +134,12 @@ class GPEXP_OT_render_auto_build(bpy.types.Operator):
if ret != {'FINISHED'}: if ret != {'FINISHED'}:
print('No GP render workspace available') print('No GP render workspace available')
## Group all adjacent layer type bpy.app.timers.register(batch_setup_render_scene, first_interval=0.001)
print('Group all adjacent layer type')
for ob in ob_list:
fn.group_adjacent_layer_prefix_rlayer(ob, excluded_prefix=['GP', 'PO', 'RG'], first_name=True)
# bpy.ops.gp_export.render_scene_setup() # next render scene setup at once
## Renumber File outputs
print('Renumber File outputs')
for fo in render_scn.node_tree.nodes:
if fo.type == 'OUTPUT_FILE':
fn.renumber_keep_existing(fo)
## Swap to bg_cam (if any)
if render_scn.objects.get('bg_cam') and (not render_scn.camera or render_scn.camera.name != 'bg_cam'):
print('Swap to bg cam')
bpy.ops.gp.swap_render_cams()
## Go to camera view in visible viewports
if render_scn.camera:
print('Go to camera view in visible viewports')
for window in bpy.context.window_manager.windows:
screen = window.screen
for area in screen.areas:
if area.type == 'VIEW_3D':
area.spaces.active.region_3d.view_perspective = 'CAMERA'
## Clean compo Tree
print('Clean compo Tree')
# bpy.ops.gp.clean_compo_tree('INVOKE_DEFAULT', use_render_scene=True)
bpy.ops.gp.clean_compo_tree('EXEC_DEFAULT', use_render_scene=True)
## Trigger check file before finishing ? ## Trigger check file before finishing ?
# bpy.ops.gp.check_render_scene('INVOKE_DEFAULT') # bpy.ops.gp.check_render_scene('INVOKE_DEFAULT')
## Note: After all these operation, a ctrl+Z might crash ## Note: After all these operation, a ctrl+Z might crash
print('\nDone.') print('\nDone.')
return {"FINISHED"} return {"FINISHED"}

View File

@ -120,6 +120,8 @@ class GPEXP_OT_clean_compo_tree(bpy.types.Operator):
render = context.scene render = context.scene
nodes = render.node_tree.nodes nodes = render.node_tree.nodes
for n in nodes:
n.update()
if self.clear_unused_view_layers: if self.clear_unused_view_layers:
used_rlayer_names = [n.layer for n in nodes if n.type == 'R_LAYERS'] used_rlayer_names = [n.layer for n in nodes if n.type == 'R_LAYERS']
for rl in reversed(render.view_layers): for rl in reversed(render.view_layers):