add resolutoin in crop_infos

1.3.6

- added: scene resolution in json crop pixels information, per objects
- changed: fixed name `crop_infos.json` for exported crop pixels information
main
pullusb 2023-06-20 14:37:39 +02:00
parent 4e2ea0e122
commit ee03cf734b
3 changed files with 18 additions and 9 deletions

View File

@ -14,6 +14,11 @@ Activate / deactivate layer opacity according to prefix
Activate / deactivate all masks using MA layers Activate / deactivate all masks using MA layers
--> -->
1.3.6
- added: scene resolution in json crop pixels information, per objects
- changed: fixed name `crop_infos.json` for exported crop pixels information
1.3.5 1.3.5
- added: button to exclude viewlayers and nodes by selection or by hided layers - added: button to exclude viewlayers and nodes by selection or by hided layers

View File

@ -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": (1, 3, 5), "version": (1, 3, 6),
"blender": (2, 93, 0), "blender": (2, 93, 0),
"location": "View3D", "location": "View3D",
"warning": "", "warning": "",

20
fn.py
View File

@ -1141,11 +1141,11 @@ def show_message_box(_message = "", _title = "Message Box", _icon = 'INFO'):
## -- camera framing and object anim checks ## -- camera framing and object anim checks
def get_bbox_3d(ob): def get_bbox_3d(ob) -> list:
bbox_coords = ob.bound_box bbox_coords = ob.bound_box
return [ob.matrix_world @ Vector(b) for b in bbox_coords] return [ob.matrix_world @ Vector(b) for b in bbox_coords]
def is_render_included(o, scn): def is_render_included(o, scn) -> bool:
'''return True if object is in at least one non-excluded collection '''return True if object is in at least one non-excluded collection
in all passed scene viewlayer in all passed scene viewlayer
''' '''
@ -1162,7 +1162,7 @@ def is_render_included(o, scn):
return False return False
def get_crop_pixel_coord(scn): def get_crop_pixel_coord(scn) -> dict:
# width height probably not needed. might need # width height probably not needed. might need
px_width = (scn.render.border_max_x - scn.render.border_min_x) * scn.render.resolution_x px_width = (scn.render.border_max_x - scn.render.border_min_x) * scn.render.resolution_x
px_height = (scn.render.border_max_y - scn.render.border_min_y) * scn.render.resolution_y px_height = (scn.render.border_max_y - scn.render.border_min_y) * scn.render.resolution_y
@ -1180,18 +1180,22 @@ def get_crop_pixel_coord(scn):
'position_y' : round(pos_y), 'position_y' : round(pos_y),
'width' : round(px_width), 'width' : round(px_width),
'height' : round(px_height), 'height' : round(px_height),
'scene_res_x': scn.render.resolution_x,
'scene_res_y': scn.render.resolution_y,
} }
return coord return coord
def export_crop_to_json(): def export_crop_to_json() -> dict:
'''Export crop to json coords for AE '''Export crop to json coords for AE'''
'''
blend = Path(bpy.data.filepath) blend = Path(bpy.data.filepath)
json_path = blend.parent / 'render' / f'{blend.stem}.json' #f'{ob.name}.json' ## Use a fixed name (easier to load from After effects)
json_path = blend.parent / 'render' / 'crop_infos.json'
## Use blend name (to support version)
# json_path = blend.parent / 'render' / f'{blend.stem}.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'
coord_dic = {} coord_dic = {}