From de62448a5df24571400f0dba1294c593be1c4eb1 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 19 Jul 2023 11:18:35 -0400 Subject: [PATCH 01/18] Blender Kitsu: Add popup warning for Frame Range --- .../addons/blender_kitsu/playblast/ops.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/scripts-blender/addons/blender_kitsu/playblast/ops.py b/scripts-blender/addons/blender_kitsu/playblast/ops.py index a9ab3273..c7004b6f 100644 --- a/scripts-blender/addons/blender_kitsu/playblast/ops.py +++ b/scripts-blender/addons/blender_kitsu/playblast/ops.py @@ -443,6 +443,12 @@ def load_post_handler_init_version_model(dummy: Any) -> None: opsdata.init_playblast_file_model(bpy.context) +def draw_frame_range_warning(self, context): + layout = self.layout + layout.alert = True + layout.label(text="Please update Frame Range") + + @persistent def load_post_handler_check_frame_range(dummy: Any) -> None: """ @@ -452,6 +458,13 @@ def load_post_handler_check_frame_range(dummy: Any) -> None: """ active_shot = cache.shot_active_get() if not active_shot: + bpy.ops.kitsu.print_report() + logger.warning("Active Shot was not found on server.") + bpy.context.window_manager.popup_menu( + draw_frame_range_warning, + title="Warning: Frame Range Error.", + icon='ERROR', + ) return # Pull update for shot. @@ -473,6 +486,11 @@ def load_post_handler_check_frame_range(dummy: Any) -> None: return bpy.context.scene.kitsu_error.frame_range = True + bpy.context.window_manager.popup_menu( + draw_frame_range_warning, + title="Warning: Frame Range Error.", + icon='ERROR', + ) logger.warning("Current frame range is outdated!") -- 2.30.2 From 3d013499223e2e380bc77d2b03ffc9ceb3c401da Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 19 Jul 2023 11:18:36 -0400 Subject: [PATCH 02/18] Blender Kitsu: Add Operator to Frame Range Warning --- scripts-blender/addons/blender_kitsu/playblast/ops.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts-blender/addons/blender_kitsu/playblast/ops.py b/scripts-blender/addons/blender_kitsu/playblast/ops.py index c7004b6f..fc34d827 100644 --- a/scripts-blender/addons/blender_kitsu/playblast/ops.py +++ b/scripts-blender/addons/blender_kitsu/playblast/ops.py @@ -446,7 +446,7 @@ def load_post_handler_init_version_model(dummy: Any) -> None: def draw_frame_range_warning(self, context): layout = self.layout layout.alert = True - layout.label(text="Please update Frame Range") + layout.operator("kitsu.pull_frame_range") @persistent -- 2.30.2 From 3304c08aa82562bb8deb8ef099b7b73440705e75 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 19 Jul 2023 11:18:36 -0400 Subject: [PATCH 03/18] Blender Kitsu: Improve Frame Range Operator UI - Make Row Red to catch user attention - Update Icon for Pull Frame Range --- scripts-blender/addons/blender_kitsu/ui.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts-blender/addons/blender_kitsu/ui.py b/scripts-blender/addons/blender_kitsu/ui.py index f01146f5..62681bc9 100644 --- a/scripts-blender/addons/blender_kitsu/ui.py +++ b/scripts-blender/addons/blender_kitsu/ui.py @@ -50,10 +50,10 @@ def draw_error_invalid_playblast_root_dir( def draw_error_frame_range_outdated( box: bpy.types.UILayout, ) -> bpy.types.UILayout: - row = box.row(align=True) + row.alert = True row.label(text="Frame Range Outdated") - row.operator("kitsu.pull_frame_range", icon="FILE_REFRESH") + row.operator("kitsu.pull_frame_range", icon="TRIA_DOWN") def draw_error_invalid_render_preset_dir( -- 2.30.2 From 8b992410c06f968d5eb0a99a29bdb6b49a86514a Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 19 Jul 2023 11:18:37 -0400 Subject: [PATCH 04/18] Blender Kitsu: Improve Frame Range Warning --- .../addons/blender_kitsu/playblast/ops.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts-blender/addons/blender_kitsu/playblast/ops.py b/scripts-blender/addons/blender_kitsu/playblast/ops.py index fc34d827..a0bbd057 100644 --- a/scripts-blender/addons/blender_kitsu/playblast/ops.py +++ b/scripts-blender/addons/blender_kitsu/playblast/ops.py @@ -444,9 +444,20 @@ def load_post_handler_init_version_model(dummy: Any) -> None: def draw_frame_range_warning(self, context): + active_shot = cache.shot_active_get() layout = self.layout layout.alert = True - layout.operator("kitsu.pull_frame_range") + layout.label( + text="Frame Range on server does not match the active shot. Please 'pull' the correct frame range from the server" + ) + layout.label( + text=f" File Frame Range: {context.scene.frame_start}-{context.scene.frame_end}" + ) + layout.label( + text=f' Server Frame Range: {int(active_shot.data["3d_start"])}-{int(active_shot.data["3d_start"]) + int(active_shot.nb_frames) - 1}' + ) + + layout.operator("kitsu.pull_frame_range", icon='TRIA_DOWN') @persistent -- 2.30.2 From 64d0432d250fbac81f8ab2c4f02171dca2ce5922 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 19 Jul 2023 11:18:38 -0400 Subject: [PATCH 05/18] Blender Kitsu: Add Warning for Failed Kitsu Context --- scripts-blender/addons/blender_kitsu/playblast/ops.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts-blender/addons/blender_kitsu/playblast/ops.py b/scripts-blender/addons/blender_kitsu/playblast/ops.py index a0bbd057..7672af2b 100644 --- a/scripts-blender/addons/blender_kitsu/playblast/ops.py +++ b/scripts-blender/addons/blender_kitsu/playblast/ops.py @@ -443,6 +443,12 @@ def load_post_handler_init_version_model(dummy: Any) -> None: opsdata.init_playblast_file_model(bpy.context) +def draw_frame_range_failed_context(self, context): + layout = self.layout + layout.alert = True + layout.label(text="Kitsu Context could not be detected from current file") + + def draw_frame_range_warning(self, context): active_shot = cache.shot_active_get() layout = self.layout @@ -469,11 +475,10 @@ def load_post_handler_check_frame_range(dummy: Any) -> None: """ active_shot = cache.shot_active_get() if not active_shot: - bpy.ops.kitsu.print_report() logger.warning("Active Shot was not found on server.") bpy.context.window_manager.popup_menu( - draw_frame_range_warning, - title="Warning: Frame Range Error.", + draw_frame_range_failed_context, + title="Warning: Kitsu Context Failed.", icon='ERROR', ) return -- 2.30.2 From 0afa39fc5a72f574e68d6d096787b90d2cbbf6c6 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 19 Jul 2023 11:18:38 -0400 Subject: [PATCH 06/18] Blender Kitsu: Add Core Functions to Get/Set and Check Frame Range --- .../addons/blender_kitsu/playblast/core.py | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/scripts-blender/addons/blender_kitsu/playblast/core.py b/scripts-blender/addons/blender_kitsu/playblast/core.py index 0da6342e..e865cbff 100644 --- a/scripts-blender/addons/blender_kitsu/playblast/core.py +++ b/scripts-blender/addons/blender_kitsu/playblast/core.py @@ -255,3 +255,83 @@ def playblast_user_shading_settings(self, context, file_path): # Make opengl render. bpy.ops.render.opengl(animation=True) return output_path + + +def draw_frame_range_failed_context(self, context): + layout = self.layout + layout.alert = True + layout.label(text="Kitsu Context could not be detected from current file") + + +def draw_frame_range_warning(self, context): + active_shot = cache.shot_active_get() + layout = self.layout + layout.alert = True + layout.label( + text="Frame Range on server does not match the active shot. Please 'pull' the correct frame range from the server" + ) + layout.label( + text=f" File Frame Range: {context.scene.frame_start}-{context.scene.frame_end}" + ) + layout.label( + text=f' Server Frame Range: {int(active_shot.data["3d_start"])}-{int(active_shot.data["3d_start"]) + int(active_shot.nb_frames) - 1}' + ) + + layout.operator("kitsu.pull_frame_range", icon='TRIA_DOWN') + + +def set_frame_range_in(frame_in: int): + shot = cache.shot_active_pull_update() + shot.data["3d_start"] = frame_in + shot.update() + return shot + + +def get_frame_range(): + active_shot = cache.shot_active_get() + if not active_shot: + logger.warning("Active Shot was not found on server.") + bpy.context.window_manager.popup_menu( + draw_frame_range_failed_context, + title="Warning: Kitsu Context Failed.", + icon='ERROR', + ) + return + + # Pull update for shot. + cache.shot_active_pull_update() + if "3d_start" not in active_shot.data: + logger.warning( + "Failed to check frame range. Shot %s missing '3d_start' attribute on server", + active_shot.name, + ) + return + frame_in = int(active_shot.data["3d_start"]) + frame_out = int(active_shot.data["3d_start"]) + int(active_shot.nb_frames) - 1 + return frame_in, frame_out + + +def check_frame_range(): + """ + Compare the current scene's frame range with that of the active shot on kitsu. + If there's a mismatch, set kitsu_error.frame_range -> True. This will enable + a warning in the Animation Tools Tab UI. + """ + frame_in, frame_out = get_frame_range() + frame_range_correct = bpy.context.scene.kitsu_error.frame_range + + if ( + frame_in == bpy.context.scene.frame_start + and frame_out == bpy.context.scene.frame_end + ): + frame_range_correct = True + return frame_range_correct + + bpy.context.window_manager.popup_menu( + draw_frame_range_warning, + title="Warning: Frame Range Error.", + icon='ERROR', + ) + frame_range_correct = False + logger.warning("Current frame range is outdated!") + return frame_range_correct -- 2.30.2 From 8269dddcfc64e13c0f1d77a8c40b97fdb3aa5eed Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 19 Jul 2023 11:18:39 -0400 Subject: [PATCH 07/18] Blender Kitsu: Remove duplicate code --- .../addons/blender_kitsu/playblast/ops.py | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/scripts-blender/addons/blender_kitsu/playblast/ops.py b/scripts-blender/addons/blender_kitsu/playblast/ops.py index 7672af2b..f9765ad2 100644 --- a/scripts-blender/addons/blender_kitsu/playblast/ops.py +++ b/scripts-blender/addons/blender_kitsu/playblast/ops.py @@ -443,29 +443,6 @@ def load_post_handler_init_version_model(dummy: Any) -> None: opsdata.init_playblast_file_model(bpy.context) -def draw_frame_range_failed_context(self, context): - layout = self.layout - layout.alert = True - layout.label(text="Kitsu Context could not be detected from current file") - - -def draw_frame_range_warning(self, context): - active_shot = cache.shot_active_get() - layout = self.layout - layout.alert = True - layout.label( - text="Frame Range on server does not match the active shot. Please 'pull' the correct frame range from the server" - ) - layout.label( - text=f" File Frame Range: {context.scene.frame_start}-{context.scene.frame_end}" - ) - layout.label( - text=f' Server Frame Range: {int(active_shot.data["3d_start"])}-{int(active_shot.data["3d_start"]) + int(active_shot.nb_frames) - 1}' - ) - - layout.operator("kitsu.pull_frame_range", icon='TRIA_DOWN') - - @persistent def load_post_handler_check_frame_range(dummy: Any) -> None: """ -- 2.30.2 From ee5d70660920a214248c69187d6f24d969a42ee3 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 19 Jul 2023 11:18:39 -0400 Subject: [PATCH 08/18] Blender Kitsu: Use core function in frame range post handler --- .../addons/blender_kitsu/playblast/ops.py | 41 +------------------ 1 file changed, 1 insertion(+), 40 deletions(-) diff --git a/scripts-blender/addons/blender_kitsu/playblast/ops.py b/scripts-blender/addons/blender_kitsu/playblast/ops.py index f9765ad2..7bf1ddce 100644 --- a/scripts-blender/addons/blender_kitsu/playblast/ops.py +++ b/scripts-blender/addons/blender_kitsu/playblast/ops.py @@ -445,46 +445,7 @@ def load_post_handler_init_version_model(dummy: Any) -> None: @persistent def load_post_handler_check_frame_range(dummy: Any) -> None: - """ - Compare the current scene's frame range with that of the active shot on kitsu. - If there's a mismatch, set kitsu_error.frame_range -> True. This will enable - a warning in the Animation Tools Tab UI. - """ - active_shot = cache.shot_active_get() - if not active_shot: - logger.warning("Active Shot was not found on server.") - bpy.context.window_manager.popup_menu( - draw_frame_range_failed_context, - title="Warning: Kitsu Context Failed.", - icon='ERROR', - ) - return - - # Pull update for shot. - cache.shot_active_pull_update() - - if "3d_start" not in active_shot.data: - logger.warning( - "Failed to check frame range. Shot %s missing '3d_start' attribute on server", - active_shot.name, - ) - return - frame_in = int(active_shot.data["3d_start"]) - frame_out = int(active_shot.data["3d_start"]) + int(active_shot.nb_frames) - 1 - if ( - frame_in == bpy.context.scene.frame_start - and frame_out == bpy.context.scene.frame_end - ): - bpy.context.scene.kitsu_error.frame_range = False - return - - bpy.context.scene.kitsu_error.frame_range = True - bpy.context.window_manager.popup_menu( - draw_frame_range_warning, - title="Warning: Frame Range Error.", - icon='ERROR', - ) - logger.warning("Current frame range is outdated!") + core.check_frame_range() @persistent -- 2.30.2 From 60416fbc3c0d74dc635482deea3b5d71398b9435 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 19 Jul 2023 11:18:40 -0400 Subject: [PATCH 09/18] Blender Kitsu: Use core function Pull Frame Range --- .../addons/blender_kitsu/playblast/ops.py | 25 ++++++------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/scripts-blender/addons/blender_kitsu/playblast/ops.py b/scripts-blender/addons/blender_kitsu/playblast/ops.py index 7bf1ddce..301e78ea 100644 --- a/scripts-blender/addons/blender_kitsu/playblast/ops.py +++ b/scripts-blender/addons/blender_kitsu/playblast/ops.py @@ -383,23 +383,10 @@ class KITSU_OT_pull_frame_range(bpy.types.Operator): return bool(prefs.session_auth(context) and cache.shot_active_get()) def execute(self, context: bpy.types.Context) -> Set[str]: - active_shot = cache.shot_active_pull_update() - - if "3d_start" not in active_shot.data: - self.report( - {"ERROR"}, - f"Failed to pull frame range. Shot {active_shot.name} missing '3d_start'.", - ) - return {"CANCELLED"} - - frame_in = int(active_shot.data["3d_start"]) - frame_out = int(active_shot.data["3d_start"]) + int(active_shot.nb_frames) - 1 + frame_in, frame_out = core.get_frame_range() # Check if current frame range matches the one for active shot. - if ( - frame_in == context.scene.frame_start - and frame_out == context.scene.frame_end - ): + if core.check_frame_range(): self.report({"INFO"}, f"Frame range already up to date") return {"FINISHED"} @@ -407,9 +394,11 @@ class KITSU_OT_pull_frame_range(bpy.types.Operator): context.scene.frame_start = frame_in context.scene.frame_end = frame_out - # Update error prop. - context.scene.kitsu_error.frame_range = False - + if not core.check_frame_range(): + self.report( + {"ERROR"}, f"Failed to update frame range to {frame_in} - {frame_out}" + ) + return {"CANCELLED"} # Log. self.report({"INFO"}, f"Updated frame range {frame_in} - {frame_out}") return {"FINISHED"} -- 2.30.2 From 85823f7e6065e9e54893c77e43a3a7181923795a Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 19 Jul 2023 11:18:41 -0400 Subject: [PATCH 10/18] Blender Kitsu: Use core function in Push Frame Range --- .../addons/blender_kitsu/playblast/ops.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/scripts-blender/addons/blender_kitsu/playblast/ops.py b/scripts-blender/addons/blender_kitsu/playblast/ops.py index 301e78ea..64db5d1b 100644 --- a/scripts-blender/addons/blender_kitsu/playblast/ops.py +++ b/scripts-blender/addons/blender_kitsu/playblast/ops.py @@ -348,6 +348,8 @@ class KITSU_OT_push_frame_range(bpy.types.Operator): bl_options = {"REGISTER", "UNDO"} bl_description = "Adjusts the start frame of animation file." + frame_start = None + @classmethod def poll(cls, context: bpy.types.Context) -> bool: return bool(prefs.session_auth(context) and cache.shot_active_get()) @@ -356,16 +358,22 @@ class KITSU_OT_push_frame_range(bpy.types.Operator): layout = self.layout col = layout.column(align=True) col.label(text="Set 3d_start using current scene frame start.") - col.label(text=f"New Frame Start: {context.scene.frame_start}", icon="ERROR") + col.label(text=f"New Frame Start: {self.frame_start}", icon="ERROR") def execute(self, context: bpy.types.Context) -> Set[str]: - shot = cache.shot_active_pull_update() - shot.data["3d_start"] = context.scene.frame_start - shot.update() - self.report({"INFO"}, f"Updated frame range offset {context.scene.frame_start}") + core.set_frame_range_in(self.frame_start) + self.report({"INFO"}, f"Updated frame range offset {self.frame_start}") return {"FINISHED"} def invoke(self, context: bpy.types.Context, event: bpy.types.Event) -> Set[str]: + self.frame_start = context.scene.frame_start + frame_in, _ = core.get_frame_range() + if frame_in == self.frame_start: + self.report( + {"INFO"}, + f"Sever's 'Frame In' already matches current Scene's 'Frame Start' {self.frame_start}", + ) + return {"FINISHED"} return context.window_manager.invoke_props_dialog(self, width=500) -- 2.30.2 From d1f90d7f17e5e834be95751a22a6c824f3774433 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 19 Jul 2023 11:18:41 -0400 Subject: [PATCH 11/18] Blender Kitsu: Restore Missing Import --- scripts-blender/addons/blender_kitsu/playblast/ops.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts-blender/addons/blender_kitsu/playblast/ops.py b/scripts-blender/addons/blender_kitsu/playblast/ops.py index 64db5d1b..119146ea 100644 --- a/scripts-blender/addons/blender_kitsu/playblast/ops.py +++ b/scripts-blender/addons/blender_kitsu/playblast/ops.py @@ -44,7 +44,7 @@ from blender_kitsu.playblast.core import ( playblast_with_shading_settings, playblast_user_shading_settings, ) -from blender_kitsu.playblast import opsdata +from blender_kitsu.playblast import opsdata, core logger = LoggerFactory.getLogger() -- 2.30.2 From a9ab9538ac4d9d79e211ff6ed546e2432ad0f467 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 19 Jul 2023 11:18:42 -0400 Subject: [PATCH 12/18] Blender Kitsu: Fix broken import --- scripts-blender/addons/blender_kitsu/playblast/core.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts-blender/addons/blender_kitsu/playblast/core.py b/scripts-blender/addons/blender_kitsu/playblast/core.py index e865cbff..582def89 100644 --- a/scripts-blender/addons/blender_kitsu/playblast/core.py +++ b/scripts-blender/addons/blender_kitsu/playblast/core.py @@ -3,9 +3,9 @@ from pathlib import Path import contextlib -from blender_kitsu import ( - prefs, -) +from blender_kitsu import prefs, cache +from blender_kitsu.logger import LoggerFactory +logger = LoggerFactory.getLogger() @contextlib.contextmanager -- 2.30.2 From 10ff6cf911eeb004987bb29838972b486f4dbc59 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 19 Jul 2023 11:18:42 -0400 Subject: [PATCH 13/18] Blender Kitsu: Move Error Reporting to Load_Post_Handler --- .../addons/blender_kitsu/playblast/core.py | 40 ++----------------- .../addons/blender_kitsu/playblast/ops.py | 27 ++++++++++++- 2 files changed, 29 insertions(+), 38 deletions(-) diff --git a/scripts-blender/addons/blender_kitsu/playblast/core.py b/scripts-blender/addons/blender_kitsu/playblast/core.py index 582def89..f3a0a512 100644 --- a/scripts-blender/addons/blender_kitsu/playblast/core.py +++ b/scripts-blender/addons/blender_kitsu/playblast/core.py @@ -257,45 +257,16 @@ def playblast_user_shading_settings(self, context, file_path): return output_path -def draw_frame_range_failed_context(self, context): - layout = self.layout - layout.alert = True - layout.label(text="Kitsu Context could not be detected from current file") - - -def draw_frame_range_warning(self, context): - active_shot = cache.shot_active_get() - layout = self.layout - layout.alert = True - layout.label( - text="Frame Range on server does not match the active shot. Please 'pull' the correct frame range from the server" - ) - layout.label( - text=f" File Frame Range: {context.scene.frame_start}-{context.scene.frame_end}" - ) - layout.label( - text=f' Server Frame Range: {int(active_shot.data["3d_start"])}-{int(active_shot.data["3d_start"]) + int(active_shot.nb_frames) - 1}' - ) - - layout.operator("kitsu.pull_frame_range", icon='TRIA_DOWN') - - -def set_frame_range_in(frame_in: int): +def set_frame_range_in(frame_in: int) -> dict: shot = cache.shot_active_pull_update() shot.data["3d_start"] = frame_in shot.update() return shot -def get_frame_range(): +def get_frame_range(): # TODO return type active_shot = cache.shot_active_get() if not active_shot: - logger.warning("Active Shot was not found on server.") - bpy.context.window_manager.popup_menu( - draw_frame_range_failed_context, - title="Warning: Kitsu Context Failed.", - icon='ERROR', - ) return # Pull update for shot. @@ -311,7 +282,7 @@ def get_frame_range(): return frame_in, frame_out -def check_frame_range(): +def check_frame_range() -> bool: """ Compare the current scene's frame range with that of the active shot on kitsu. If there's a mismatch, set kitsu_error.frame_range -> True. This will enable @@ -327,11 +298,6 @@ def check_frame_range(): frame_range_correct = True return frame_range_correct - bpy.context.window_manager.popup_menu( - draw_frame_range_warning, - title="Warning: Frame Range Error.", - icon='ERROR', - ) frame_range_correct = False logger.warning("Current frame range is outdated!") return frame_range_correct diff --git a/scripts-blender/addons/blender_kitsu/playblast/ops.py b/scripts-blender/addons/blender_kitsu/playblast/ops.py index 119146ea..06f24164 100644 --- a/scripts-blender/addons/blender_kitsu/playblast/ops.py +++ b/scripts-blender/addons/blender_kitsu/playblast/ops.py @@ -440,9 +440,34 @@ def load_post_handler_init_version_model(dummy: Any) -> None: opsdata.init_playblast_file_model(bpy.context) +def draw_frame_range_warning(self, context): + active_shot = cache.shot_active_get() + layout = self.layout + layout.alert = True + layout.label( + text="Frame Range on server does not match the active shot. Please 'pull' the correct frame range from the server" + ) + layout.label( + text=f" File Frame Range: {context.scene.frame_start}-{context.scene.frame_end}" + ) + if active_shot: + layout.label( + text=f' Server Frame Range: {int(active_shot.data["3d_start"])}-{int(active_shot.data["3d_start"]) + int(active_shot.nb_frames) - 1}' + ) + else: + layout.label(text=f' Server Frame Range: not found') + + layout.operator("kitsu.pull_frame_range", icon='TRIA_DOWN') + + @persistent def load_post_handler_check_frame_range(dummy: Any) -> None: - core.check_frame_range() + if not core.check_frame_range(): + bpy.context.window_manager.popup_menu( + draw_frame_range_warning, + title="Warning: Frame Range Error.", + icon='ERROR', + ) @persistent -- 2.30.2 From e70fd35970c66a9ae08641e56eb97a9bb25d8e2c Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 19 Jul 2023 11:18:43 -0400 Subject: [PATCH 14/18] Blender Kitsu: Add Check Frame Range Operator --- .../addons/blender_kitsu/playblast/ops.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/scripts-blender/addons/blender_kitsu/playblast/ops.py b/scripts-blender/addons/blender_kitsu/playblast/ops.py index 06f24164..37ff1651 100644 --- a/scripts-blender/addons/blender_kitsu/playblast/ops.py +++ b/scripts-blender/addons/blender_kitsu/playblast/ops.py @@ -412,6 +412,26 @@ class KITSU_OT_pull_frame_range(bpy.types.Operator): return {"FINISHED"} +class KITSU_OT_check_frame_range(bpy.types.Operator): + bl_idname = "kitsu.check_frame_range" + bl_label = "Check Frame Range" + bl_options = {"REGISTER", "UNDO"} + bl_description = ( + "Checks frame range of active shot from the server matches current file" + ) + + @classmethod + def poll(cls, context: bpy.types.Context) -> bool: + return bool(prefs.session_auth(context) and cache.shot_active_get()) + + def execute(self, context: bpy.types.Context) -> Set[str]: + if core.check_frame_range(): + self.report({"INFO"}, f"Frame Range is accurate") + return {"FINISHED"} + self.report({"ERROR"}, f"Failed: Frame Range Check") + return {"CANCELLED"} + + class KITSU_OT_playblast_increment_playblast_version(bpy.types.Operator): bl_idname = "kitsu.anim_increment_playblast_version" bl_label = "Add Version Increment" @@ -500,6 +520,7 @@ classes = [ KITSU_OT_playblast_increment_playblast_version, KITSU_OT_pull_frame_range, KITSU_OT_push_frame_range, + KITSU_OT_check_frame_range, ] -- 2.30.2 From 02e85e8e662ec8cab91b417733cbb9f0ddf0c176 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 19 Jul 2023 11:18:43 -0400 Subject: [PATCH 15/18] Blender Kitsu: check_frame_range() pass context --- scripts-blender/addons/blender_kitsu/playblast/core.py | 2 +- scripts-blender/addons/blender_kitsu/playblast/ops.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts-blender/addons/blender_kitsu/playblast/core.py b/scripts-blender/addons/blender_kitsu/playblast/core.py index f3a0a512..9ebff17f 100644 --- a/scripts-blender/addons/blender_kitsu/playblast/core.py +++ b/scripts-blender/addons/blender_kitsu/playblast/core.py @@ -282,7 +282,7 @@ def get_frame_range(): # TODO return type return frame_in, frame_out -def check_frame_range() -> bool: +def check_frame_range(context) -> bool: """ Compare the current scene's frame range with that of the active shot on kitsu. If there's a mismatch, set kitsu_error.frame_range -> True. This will enable diff --git a/scripts-blender/addons/blender_kitsu/playblast/ops.py b/scripts-blender/addons/blender_kitsu/playblast/ops.py index 37ff1651..ad1543a8 100644 --- a/scripts-blender/addons/blender_kitsu/playblast/ops.py +++ b/scripts-blender/addons/blender_kitsu/playblast/ops.py @@ -394,7 +394,7 @@ class KITSU_OT_pull_frame_range(bpy.types.Operator): frame_in, frame_out = core.get_frame_range() # Check if current frame range matches the one for active shot. - if core.check_frame_range(): + if core.check_frame_range(context): self.report({"INFO"}, f"Frame range already up to date") return {"FINISHED"} @@ -402,7 +402,7 @@ class KITSU_OT_pull_frame_range(bpy.types.Operator): context.scene.frame_start = frame_in context.scene.frame_end = frame_out - if not core.check_frame_range(): + if not core.check_frame_range(context): self.report( {"ERROR"}, f"Failed to update frame range to {frame_in} - {frame_out}" ) @@ -425,7 +425,7 @@ class KITSU_OT_check_frame_range(bpy.types.Operator): return bool(prefs.session_auth(context) and cache.shot_active_get()) def execute(self, context: bpy.types.Context) -> Set[str]: - if core.check_frame_range(): + if core.check_frame_range(context): self.report({"INFO"}, f"Frame Range is accurate") return {"FINISHED"} self.report({"ERROR"}, f"Failed: Frame Range Check") @@ -482,7 +482,7 @@ def draw_frame_range_warning(self, context): @persistent def load_post_handler_check_frame_range(dummy: Any) -> None: - if not core.check_frame_range(): + if not core.check_frame_range(bpy.context): bpy.context.window_manager.popup_menu( draw_frame_range_warning, title="Warning: Frame Range Error.", -- 2.30.2 From e17afc39e54eff64f1b472868a708bb2baac0520 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 19 Jul 2023 11:18:44 -0400 Subject: [PATCH 16/18] Blender Kitsu: Fix Frame Range Warning if No Shot is Found --- .../addons/blender_kitsu/playblast/core.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts-blender/addons/blender_kitsu/playblast/core.py b/scripts-blender/addons/blender_kitsu/playblast/core.py index 9ebff17f..bef3d08c 100644 --- a/scripts-blender/addons/blender_kitsu/playblast/core.py +++ b/scripts-blender/addons/blender_kitsu/playblast/core.py @@ -5,6 +5,7 @@ import contextlib from blender_kitsu import prefs, cache from blender_kitsu.logger import LoggerFactory + logger = LoggerFactory.getLogger() @@ -288,13 +289,14 @@ def check_frame_range(context) -> bool: If there's a mismatch, set kitsu_error.frame_range -> True. This will enable a warning in the Animation Tools Tab UI. """ - frame_in, frame_out = get_frame_range() - frame_range_correct = bpy.context.scene.kitsu_error.frame_range + try: + frame_in, frame_out = get_frame_range() + except TypeError: + return + scene = context.scene + frame_range_correct = scene.kitsu_error.frame_range - if ( - frame_in == bpy.context.scene.frame_start - and frame_out == bpy.context.scene.frame_end - ): + if frame_in == scene.frame_start and frame_out == scene.frame_end: frame_range_correct = True return frame_range_correct -- 2.30.2 From 62de6e4a15a5023e41cb2add3590e8ba1aad802e Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 19 Jul 2023 11:18:45 -0400 Subject: [PATCH 17/18] Blender Kitsu: Fix Check Frame Range core function --- scripts-blender/addons/blender_kitsu/playblast/core.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts-blender/addons/blender_kitsu/playblast/core.py b/scripts-blender/addons/blender_kitsu/playblast/core.py index bef3d08c..b0417491 100644 --- a/scripts-blender/addons/blender_kitsu/playblast/core.py +++ b/scripts-blender/addons/blender_kitsu/playblast/core.py @@ -294,12 +294,11 @@ def check_frame_range(context) -> bool: except TypeError: return scene = context.scene - frame_range_correct = scene.kitsu_error.frame_range if frame_in == scene.frame_start and frame_out == scene.frame_end: - frame_range_correct = True - return frame_range_correct + scene.kitsu_error.frame_range = False + return True - frame_range_correct = False + scene.kitsu_error.frame_range = True logger.warning("Current frame range is outdated!") - return frame_range_correct + return False -- 2.30.2 From b8fde090587adb8393510e8db9b6ef0d0233d5ac Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 19 Jul 2023 11:18:45 -0400 Subject: [PATCH 18/18] Blender Kitsu: Only show Frame Range Pop-Up if Kitsu Context is detected --- scripts-blender/addons/blender_kitsu/playblast/ops.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts-blender/addons/blender_kitsu/playblast/ops.py b/scripts-blender/addons/blender_kitsu/playblast/ops.py index ad1543a8..d9d00e8e 100644 --- a/scripts-blender/addons/blender_kitsu/playblast/ops.py +++ b/scripts-blender/addons/blender_kitsu/playblast/ops.py @@ -482,6 +482,10 @@ def draw_frame_range_warning(self, context): @persistent def load_post_handler_check_frame_range(dummy: Any) -> None: + # Only show if kitsu context is detected + active_shot = cache.shot_active_get() + if not active_shot: + return if not core.check_frame_range(bpy.context): bpy.context.window_manager.popup_menu( draw_frame_range_warning, -- 2.30.2