multiscene viewlayer check
0.6.8 - feat: New multi-scene viewlayer inspection button - fix: revert back export json crop to use GP names when availablemain
parent
046c60cec6
commit
da86da59ce
|
@ -14,6 +14,10 @@ Activate / deactivate layer opaticty according to prefix
|
||||||
Activate / deactivate all masks using MA layers
|
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
|
0.6.7
|
||||||
|
|
||||||
|
|
|
@ -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_description = "Export json of all scenes borders (when enabled)" # Automatic set crop from selection
|
||||||
bl_options = {"REGISTER"}
|
bl_options = {"REGISTER"}
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def poll(cls, context):
|
|
||||||
return True
|
|
||||||
|
|
||||||
def execute(self, context):
|
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:
|
# 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!')
|
# self.report({'ERROR'}, 'Current scene have cropping disabled or use crop_to_border disabled!')
|
||||||
# return {'CANCELLED'}
|
# return {'CANCELLED'}
|
||||||
crop_dic = fn.export_crop_to_json()
|
crop_dic = fn.export_crop_to_json()
|
||||||
if not crop_dic:
|
if not crop_dic:
|
||||||
self.report({'ERROR'}, 'No crop to export (Border might be deactivated in all scenes)')
|
self.report({'ERROR'}, 'No crop to export (Border might be deactivated in all scenes)')
|
||||||
|
# else:
|
||||||
|
# self.report({'INFO'}, 'Json saved')
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ bl_info = {
|
||||||
"name": "GP Render",
|
"name": "GP Render",
|
||||||
"description": "Organise export of gp layers through compositor output",
|
"description": "Organise export of gp layers through compositor output",
|
||||||
"author": "Samuel Bernou",
|
"author": "Samuel Bernou",
|
||||||
"version": (0, 6, 7),
|
"version": (0, 6, 8),
|
||||||
"blender": (2, 93, 0),
|
"blender": (2, 93, 0),
|
||||||
"location": "View3D",
|
"location": "View3D",
|
||||||
"warning": "",
|
"warning": "",
|
||||||
|
|
24
fn.py
24
fn.py
|
@ -814,7 +814,6 @@ def export_crop_to_json():
|
||||||
blend = Path(bpy.data.filepath)
|
blend = Path(bpy.data.filepath)
|
||||||
json_path = blend.parent / 'render' / f'{blend.stem}.json' #f'{ob.name}.json'
|
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'
|
## 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'
|
# json_path = Path(bpy.data.filepath).parent / 'render' / f'{scn.name}.json' #f'{ob.name}.json'
|
||||||
|
|
||||||
|
@ -824,25 +823,28 @@ def export_crop_to_json():
|
||||||
# if scn.name in {'Scene', 'Render'}:
|
# if scn.name in {'Scene', 'Render'}:
|
||||||
# if scn.name == 'Scene':
|
# if scn.name == 'Scene':
|
||||||
# continue
|
# 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)
|
scn_border = get_crop_pixel_coord(scn)
|
||||||
## use scn name
|
## 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
|
# 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
|
||||||
|
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:
|
if coord_dic:
|
||||||
json_path.parent.mkdir(parents=False, exist_ok=True)
|
json_path.parent.mkdir(parents=False, exist_ok=True)
|
||||||
# save bbox
|
# save bbox
|
||||||
with json_path.open('w') as fd:
|
with json_path.open('w') as fd:
|
||||||
json.dump(coord_dic, fd, indent='\t')
|
json.dump(coord_dic, fd, indent='\t')
|
||||||
|
|
||||||
print(f'coord saved at: {json_path}')
|
print(f'Coords saved at: {json_path}')
|
||||||
return coord_dic
|
return coord_dic
|
||||||
|
|
||||||
def set_border_region_from_coord(coords, scn=None, margin=30, export_json=True):
|
def set_border_region_from_coord(coords, scn=None, margin=30, export_json=True):
|
||||||
|
|
24
ui.py
24
ui.py
|
@ -65,6 +65,7 @@ class GPEXP_PT_gp_node_ui(Panel):
|
||||||
|
|
||||||
row2=row.row(align=True)
|
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='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("gp.viewlayer_popup", text="", icon='RENDERLAYERS') # Ops invoke hack
|
||||||
# row2.operator("wm.call_menu", text="", icon='RENDERLAYERS').name = "GPEXP_MT_viewlayers_popup" # Bad menu
|
# 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"')
|
col.label(text='- tick only "object data"')
|
||||||
|
|
||||||
|
|
||||||
def viewlayer_layout(layout, context):
|
def viewlayer_layout(layout, scn):
|
||||||
for vl in context.scene.view_layers:
|
for vl in scn.view_layers:
|
||||||
row = layout.row()
|
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' if vl.use else 'RESTRICT_RENDER_ON', emboss=False, toggle=0)
|
||||||
# row.prop(vl, 'use', text=vl.name, icon='RESTRICT_RENDER_OFF', emboss=False)
|
# 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_space_type = "NODE_EDITOR"
|
||||||
bl_region_type = "UI"
|
bl_region_type = "UI"
|
||||||
bl_label = "View Layers"
|
bl_label = "View Layers"
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
layout.label(text=f'{context.scene.name} :: View layers')
|
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):
|
class GPEXP_OT_viewlayer_popup_invoke(bpy.types.Operator):
|
||||||
bl_idname = "gp.viewlayer_popup"
|
bl_idname = "gp.viewlayer_popup"
|
||||||
|
@ -312,6 +329,7 @@ def manager_ui(self, context):
|
||||||
|
|
||||||
classes=(
|
classes=(
|
||||||
GPEXP_PT_viewlayers_ui,
|
GPEXP_PT_viewlayers_ui,
|
||||||
|
GPEXP_PT_viewlayers_multi_ui,
|
||||||
GPEXP_OT_viewlayer_popup_invoke,
|
GPEXP_OT_viewlayer_popup_invoke,
|
||||||
GPEXP_MT_multi_user_doc,
|
GPEXP_MT_multi_user_doc,
|
||||||
GPEXP_PT_gp_node_ui,
|
GPEXP_PT_gp_node_ui,
|
||||||
|
|
Loading…
Reference in New Issue