multiscene viewlayer check

0.6.8

- feat: New multi-scene viewlayer inspection button
- fix: revert back export json crop to use GP names when available
main
Pullusb 2021-11-12 15:42:32 +01:00
parent 046c60cec6
commit da86da59ce
5 changed files with 42 additions and 20 deletions

View File

@ -14,6 +14,10 @@ Activate / deactivate layer opaticty according to prefix
Activate / deactivate all masks using MA layers
-->
0.6.8
- feat: New multi-scene viewlayer inspection button
- fix: revert back export json crop to use GP names when available
0.6.7

View File

@ -28,18 +28,16 @@ class GPEXP_OT_export_crop_coord_to_json(bpy.types.Operator):
bl_description = "Export json of all scenes borders (when enabled)" # Automatic set crop from selection
bl_options = {"REGISTER"}
@classmethod
def poll(cls, context):
return True
def execute(self, context):
# scn = context.scene
# scn = context.scene (mono-scene)
# if not scn.render.use_border or not scn.render.use_crop_to_border:
# self.report({'ERROR'}, 'Current scene have cropping disabled or use crop_to_border disabled!')
# return {'CANCELLED'}
crop_dic = fn.export_crop_to_json()
if not crop_dic:
self.report({'ERROR'}, 'No crop to export (Border might be deactivated in all scenes)')
# else:
# self.report({'INFO'}, 'Json saved')
return {"FINISHED"}

View File

@ -2,7 +2,7 @@ bl_info = {
"name": "GP Render",
"description": "Organise export of gp layers through compositor output",
"author": "Samuel Bernou",
"version": (0, 6, 7),
"version": (0, 6, 8),
"blender": (2, 93, 0),
"location": "View3D",
"warning": "",

24
fn.py
View File

@ -813,7 +813,6 @@ def export_crop_to_json():
blend = Path(bpy.data.filepath)
json_path = blend.parent / 'render' / f'{blend.stem}.json' #f'{ob.name}.json'
## per scene : json_path = Path(bpy.data.filepath).parent / 'render' / f'{scn.name}.json'
# json_path = Path(bpy.data.filepath).parent / 'render' / f'{scn.name}.json' #f'{ob.name}.json'
@ -824,17 +823,20 @@ def export_crop_to_json():
# if scn.name in {'Scene', 'Render'}:
# if scn.name == 'Scene':
# continue
if scn.render.use_border:
if scn.render.use_border and scn.render.use_crop_to_border: # Only usefull if cropped
scn_border = get_crop_pixel_coord(scn)
## use scn name
coord_dic[scn.name] = scn_border
## Only scn name (meaning only one name to refer if multiple GP)
# coord_dic[scn.name] = scn_border
## use name of first found GP :
# gps = [o for o in scn.objects if o.type == 'GPENCIL']
# if gps:
# for ob in gps:
# coord_dic[ob.name] = scn_border
# else:
# coord_dic[scn.name] = scn_border
gps = [o for o in scn.objects if o.type == 'GPENCIL']
if gps:
for ob in gps:
coord_dic[ob.name] = scn_border
print(f'Added gp {ob.name} crop info')
else:
coord_dic[scn.name] = scn_border
print(f'Added scene {scn.name} crop info')
if coord_dic:
json_path.parent.mkdir(parents=False, exist_ok=True)
@ -842,7 +844,7 @@ def export_crop_to_json():
with json_path.open('w') as fd:
json.dump(coord_dic, fd, indent='\t')
print(f'coord saved at: {json_path}')
print(f'Coords saved at: {json_path}')
return coord_dic
def set_border_region_from_coord(coords, scn=None, margin=30, export_json=True):

24
ui.py
View File

@ -65,6 +65,7 @@ class GPEXP_PT_gp_node_ui(Panel):
row2=row.row(align=True)
row2.operator("wm.call_panel", text="", icon='RENDERLAYERS').name = "GPEXP_PT_viewlayers_ui"
row2.operator("wm.call_panel", text="", icon='SCENE_DATA').name = "GPEXP_PT_viewlayers_multi_ui"
# row2.operator("gp.viewlayer_popup", text="", icon='RENDERLAYERS') # Ops invoke hack
# row2.operator("wm.call_menu", text="", icon='RENDERLAYERS').name = "GPEXP_MT_viewlayers_popup" # Bad menu
@ -237,8 +238,8 @@ class GPEXP_MT_multi_user_doc(bpy.types.Menu):
col.label(text='- tick only "object data"')
def viewlayer_layout(layout, context):
for vl in context.scene.view_layers:
def viewlayer_layout(layout, scn):
for vl in scn.view_layers:
row = layout.row()
row.prop(vl, 'use', text=vl.name, icon='RESTRICT_RENDER_OFF' if vl.use else 'RESTRICT_RENDER_ON', emboss=False, toggle=0)
# row.prop(vl, 'use', text=vl.name, icon='RESTRICT_RENDER_OFF', emboss=False)
@ -254,10 +255,26 @@ class GPEXP_PT_viewlayers_ui(Panel):
bl_space_type = "NODE_EDITOR"
bl_region_type = "UI"
bl_label = "View Layers"
def draw(self, context):
layout = self.layout
layout.label(text=f'{context.scene.name} :: View layers')
viewlayer_layout(layout, context)
col = layout.column(align=True)
viewlayer_layout(col, context.scene)
class GPEXP_PT_viewlayers_multi_ui(Panel):
bl_space_type = "NODE_EDITOR"
bl_region_type = "UI"
bl_label = "Multi View Layers"
def draw(self, context):
layout = self.layout
layout.label(text=f'{len(bpy.data.scenes)} scenes :: View layers')
for s in bpy.data.scenes:
col = layout.column()
col.label(text=f'{s.name}::')
viewlayer_layout(col, s)
layout.separator()
class GPEXP_OT_viewlayer_popup_invoke(bpy.types.Operator):
bl_idname = "gp.viewlayer_popup"
@ -312,6 +329,7 @@ def manager_ui(self, context):
classes=(
GPEXP_PT_viewlayers_ui,
GPEXP_PT_viewlayers_multi_ui,
GPEXP_OT_viewlayer_popup_invoke,
GPEXP_MT_multi_user_doc,
GPEXP_PT_gp_node_ui,