Append GP render workspace from dopepsheet panel
1.2.1 - added: bundle app_template to load "GR Render" workspace from it - added: ui button in dopesheet to load GP render workspacemain
parent
544cd7bf56
commit
f3646e37df
|
@ -14,6 +14,11 @@ Activate / deactivate layer opacity according to prefix
|
|||
Activate / deactivate all masks using MA layers
|
||||
-->
|
||||
|
||||
1.2.1
|
||||
|
||||
- added: bundle app_template to load "GR Render" workspace from it
|
||||
- added: ui button in dopesheet to load GP render workspace if not loaded
|
||||
|
||||
1.2.0
|
||||
|
||||
- changed: enabled when launched in background
|
||||
|
|
|
@ -241,24 +241,11 @@ class GPEXP_OT_render_auto_build(bpy.types.Operator):
|
|||
if (render_wkspace := bpy.data.workspaces.get('GP Render')):
|
||||
context.window.workspace = render_wkspace
|
||||
else:
|
||||
render_wkspace_filepath = Path(bpy.utils.user_resource('SCRIPTS'), 'startup', 'bl_app_templates_user', 'GP', 'startup.blend')
|
||||
ret = bpy.ops.workspace.append_activate(idname='GP Render', filepath=str(render_wkspace_filepath))
|
||||
|
||||
if ret != {'FINISHED'}:
|
||||
print(f'Fallback to addon stored workspaces: (No "GP Render" found in {render_wkspace_filepath})')
|
||||
# Fallback to workspace template shipped with addon (TODO : add template blend file in addon)
|
||||
render_wkspace_filepath = Path(__file__).parent / 'workspaces' / 'startup.blend'
|
||||
ret = bpy.ops.workspace.append_activate(idname='GP Render', filepath=str(render_wkspace_filepath))
|
||||
|
||||
if ret != {'FINISHED'}:
|
||||
ret = fn.activate_workspace('GP Render')
|
||||
# render_wkspace_filepath = Path(__file__).parent / 'app_templates' / 'GP_render' / 'startup.blend'
|
||||
# ret = bpy.ops.workspace.append_activate(idname='GP Render', filepath=str(render_wkspace_filepath))
|
||||
if not ret:
|
||||
print('No GP render workspace available')
|
||||
|
||||
## extra retry after append activate ?...
|
||||
if ret == {'FINISHED'}:
|
||||
render_wkspace = bpy.data.workspaces.get('GP Render')
|
||||
if render_wkspace:
|
||||
context.window.workspace = render_wkspace
|
||||
|
||||
|
||||
# context.workspace.update_tag()
|
||||
# context.scene.update_tag()
|
||||
|
|
|
@ -89,9 +89,20 @@ class GPEXP_OT_swap_render_cams(bpy.types.Operator):
|
|||
|
||||
return {"FINISHED"}
|
||||
|
||||
class GPEXP_OT_set_gp_render_workspace(bpy.types.Operator):
|
||||
bl_idname = "gp.set_gp_render_workspace"
|
||||
bl_label = 'Set GP Render Workspace'
|
||||
bl_description = "Switch to GP render workspace, append and activate if not exists"
|
||||
bl_options = {'REGISTER', 'INTERNAL'}
|
||||
|
||||
def execute(self, context):
|
||||
fn.activate_workspace(name='GP Render', context=context)
|
||||
return {"FINISHED"}
|
||||
|
||||
classes=(
|
||||
GPEXP_OT_render_scene_switch,
|
||||
GPEXP_OT_swap_render_cams,
|
||||
GPEXP_OT_set_gp_render_workspace,
|
||||
)
|
||||
|
||||
def register():
|
||||
|
|
|
@ -2,7 +2,7 @@ bl_info = {
|
|||
"name": "GP Render",
|
||||
"description": "Organise export of gp layers through compositor output",
|
||||
"author": "Samuel Bernou",
|
||||
"version": (1, 2, 0),
|
||||
"version": (1, 2, 1),
|
||||
"blender": (2, 93, 0),
|
||||
"location": "View3D",
|
||||
"warning": "",
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
import bpy
|
||||
from bpy.app.handlers import persistent
|
||||
|
||||
@persistent
|
||||
def setup_gp_render_workspace():
|
||||
|
||||
scn = bpy.context.scene
|
||||
if not scn.camera:
|
||||
scn.camera = next((o for o in scn.objects if o.type == 'CAMERA'), None)
|
||||
|
||||
# Use rendered preview shading.
|
||||
for screen in bpy.data.screens:
|
||||
for area in screen.areas:
|
||||
for space in area.spaces:
|
||||
if space.type == 'VIEW_3D':
|
||||
space.region_3d.view_perspective = 'CAMERA'
|
||||
|
||||
def register():
|
||||
bpy.app.handlers.load_post.append(setup_gp_render_workspace)
|
||||
|
||||
def unregister():
|
||||
bpy.app.handlers.load_factory_startup_post.remove(setup_gp_render_workspace)
|
Binary file not shown.
26
fn.py
26
fn.py
|
@ -92,6 +92,31 @@ def create_aa_nodegroup(tree):
|
|||
|
||||
## -- object and scene settings
|
||||
|
||||
def activate_workspace(name='', context=None):
|
||||
if not name:
|
||||
return
|
||||
if context is None:
|
||||
context = bpy.context
|
||||
|
||||
if context.window.workspace.name == name:
|
||||
print(f'Already in {name} workspace')
|
||||
return
|
||||
|
||||
if (wkspace := bpy.data.workspaces.get(name)):
|
||||
context.window.workspace = wkspace
|
||||
return True
|
||||
|
||||
# Same name with spaces as underscore
|
||||
dir_name = name.replace(' ', '_')
|
||||
filepath = Path(__file__).parent / 'app_templates' / dir_name / 'startup.blend'
|
||||
|
||||
ret = bpy.ops.workspace.append_activate(idname=name, filepath=str(filepath))
|
||||
if ret != {'FINISHED'}:
|
||||
print(f'Could not found {name} at {filepath}')
|
||||
return False
|
||||
|
||||
return context.window.workspace
|
||||
|
||||
def copy_settings(obj_a, obj_b):
|
||||
exclusion = ['bl_rna', 'id_data', 'identifier','name_property','rna_type','properties', 'stamp_note_text','use_stamp_note',
|
||||
'settingsFilePath', 'settingsStamp', 'select', 'matrix_local', 'matrix_parent_inverse',
|
||||
|
@ -706,7 +731,6 @@ def clean_nodegroup_inputs(ng, skip_existing_pass=True):
|
|||
# a render layer of this name still exists
|
||||
continue
|
||||
ngroup.inputs.remove(ngroup.inputs[i])
|
||||
|
||||
# clear_nodegroup_content_if_disconnected(ngroup)
|
||||
|
||||
def bridge_reconnect_nodegroup(ng, socket_name=None):
|
||||
|
|
|
@ -222,7 +222,7 @@ def get_set_viewlayer_from_gp(ob, l, scene=None):
|
|||
else:
|
||||
scene = fn.get_render_scene()
|
||||
|
||||
print('Set viewlayer Scene: ', scene.name)
|
||||
# print('Set viewlayer Scene: ', scene.name)
|
||||
node_tree = scene.node_tree
|
||||
nodes = node_tree.nodes
|
||||
|
||||
|
|
8
ui.py
8
ui.py
|
@ -1,5 +1,6 @@
|
|||
import bpy
|
||||
from bpy.types import Panel
|
||||
from pathlib import Path
|
||||
from .prefs import get_addon_prefs
|
||||
# from .preferences import get_addon_prefs
|
||||
|
||||
|
@ -122,7 +123,6 @@ class GPEXP_PT_gp_node_ui(Panel):
|
|||
if advanced:
|
||||
subcol.operator('gp.set_output_node_format', icon='OUTPUT', text='Copy Active Output Format')
|
||||
subcol.operator('gp.set_active_fileout_to_compout', icon='OUTPUT', text='Active Slot to Composite')
|
||||
|
||||
|
||||
|
||||
layout.separator()
|
||||
|
@ -236,7 +236,11 @@ class GPEXP_PT_gp_dopesheet_ui(Panel):
|
|||
row = layout.row()
|
||||
row.operator('gp.export_as_pdf', icon='RENDER_STILL', text='Render All to PDF Sequences')
|
||||
if bpy.app.version < (3,0,0):
|
||||
row.label(text='Not Blender 3.0.0')
|
||||
row.label(text='Not Blender 3.0.0+')
|
||||
|
||||
## Append GP Render workspace (usefull for user with disabled 'load_UI')
|
||||
if not bpy.data.workspaces.get('GP Render'):
|
||||
layout.operator('gp.set_gp_render_workspace')
|
||||
|
||||
|
||||
class GPEXP_MT_multi_user_doc(bpy.types.Menu):
|
||||
|
|
Loading…
Reference in New Issue