Blender Kitsu: Fix Frame Range Warning #126
@ -84,6 +84,9 @@ class KITSU_PT_vi3d_context(bpy.types.Panel):
|
|||||||
row = box.row(align=True)
|
row = box.row(align=True)
|
||||||
row.label(text="Browser", icon="FILEBROWSER")
|
row.label(text="Browser", icon="FILEBROWSER")
|
||||||
|
|
||||||
|
if not context.scene.kitsu_error.kitsu_context:
|
||||||
|
ui.draw_error_no_kitsu_context(box)
|
||||||
|
else:
|
||||||
# Detect Context.
|
# Detect Context.
|
||||||
row.operator(
|
row.operator(
|
||||||
KITSU_OT_con_detect_context.bl_idname,
|
KITSU_OT_con_detect_context.bl_idname,
|
||||||
|
@ -407,9 +407,6 @@ class KITSU_OT_pull_frame_range(bpy.types.Operator):
|
|||||||
context.scene.frame_start = frame_in
|
context.scene.frame_start = frame_in
|
||||||
context.scene.frame_end = frame_out
|
context.scene.frame_end = frame_out
|
||||||
|
|
||||||
# Update error prop.
|
|
||||||
context.scene.kitsu_error.frame_range = False
|
|
||||||
|
|
||||||
# Log.
|
# Log.
|
||||||
self.report({"INFO"}, f"Updated frame range {frame_in} - {frame_out}")
|
self.report({"INFO"}, f"Updated frame range {frame_in} - {frame_out}")
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
@ -443,39 +440,6 @@ def load_post_handler_init_version_model(dummy: Any) -> None:
|
|||||||
opsdata.init_playblast_file_model(bpy.context)
|
opsdata.init_playblast_file_model(bpy.context)
|
||||||
|
|
||||||
|
|
||||||
@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:
|
|
||||||
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
|
|
||||||
logger.warning("Current frame range is outdated!")
|
|
||||||
|
|
||||||
|
|
||||||
@persistent
|
@persistent
|
||||||
def save_pre_handler_clean_overrides(dummy: Any) -> None:
|
def save_pre_handler_clean_overrides(dummy: Any) -> None:
|
||||||
"""
|
"""
|
||||||
@ -517,16 +481,12 @@ def register():
|
|||||||
|
|
||||||
# Handlers.
|
# Handlers.
|
||||||
bpy.app.handlers.load_post.append(load_post_handler_init_version_model)
|
bpy.app.handlers.load_post.append(load_post_handler_init_version_model)
|
||||||
bpy.app.handlers.load_post.append(load_post_handler_check_frame_range)
|
|
||||||
|
|
||||||
bpy.app.handlers.save_pre.append(save_pre_handler_clean_overrides)
|
bpy.app.handlers.save_pre.append(save_pre_handler_clean_overrides)
|
||||||
|
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
# Clear handlers.
|
# Clear handlers.
|
||||||
bpy.app.handlers.load_post.remove(load_post_handler_check_frame_range)
|
|
||||||
bpy.app.handlers.load_post.remove(load_post_handler_init_version_model)
|
bpy.app.handlers.load_post.remove(load_post_handler_init_version_model)
|
||||||
|
|
||||||
bpy.app.handlers.save_pre.remove(save_pre_handler_clean_overrides)
|
bpy.app.handlers.save_pre.remove(save_pre_handler_clean_overrides)
|
||||||
|
|
||||||
for cls in reversed(classes):
|
for cls in reversed(classes):
|
||||||
|
@ -24,7 +24,7 @@ from typing import Any, Union, List, Dict, Optional
|
|||||||
import bpy
|
import bpy
|
||||||
from bpy.app.handlers import persistent
|
from bpy.app.handlers import persistent
|
||||||
|
|
||||||
from blender_kitsu import propsdata, bkglobals
|
from blender_kitsu import propsdata, bkglobals, cache
|
||||||
from blender_kitsu.logger import LoggerFactory
|
from blender_kitsu.logger import LoggerFactory
|
||||||
|
|
||||||
logger = LoggerFactory.getLogger()
|
logger = LoggerFactory.getLogger()
|
||||||
@ -232,10 +232,49 @@ class KITSU_property_group_scene(bpy.types.PropertyGroup):
|
|||||||
class KITSU_property_group_error(bpy.types.PropertyGroup):
|
class KITSU_property_group_error(bpy.types.PropertyGroup):
|
||||||
""""""
|
""""""
|
||||||
|
|
||||||
|
def check_frame_range(self):
|
||||||
|
"""
|
||||||
|
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:
|
||||||
|
return True
|
||||||
|
|
||||||
|
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 True
|
||||||
|
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
|
||||||
|
):
|
||||||
|
return False
|
||||||
|
logger.warning("Current frame range is outdated!")
|
||||||
|
return True
|
||||||
|
|
||||||
|
def check_kitsu_context(self):
|
||||||
|
active_shot = cache.shot_active_get()
|
||||||
|
return bool(active_shot)
|
||||||
|
|
||||||
frame_range: bpy.props.BoolProperty( # type: ignore
|
frame_range: bpy.props.BoolProperty( # type: ignore
|
||||||
name="Frame Range Error",
|
name="Frame Range Error",
|
||||||
description="Indicates if the scene frame range does not match the one in Kitsu",
|
description="Indicates if the scene frame range does not match the one in Kitsu",
|
||||||
default=False,
|
default=False,
|
||||||
|
get=check_frame_range,
|
||||||
|
options=set(),
|
||||||
|
)
|
||||||
|
kitsu_context: bpy.props.BoolProperty( # type: ignore
|
||||||
|
name="Kitsu Context not Found",
|
||||||
|
description="Indicates if the file's context has not been loaded by Kitsu Server",
|
||||||
|
default=False,
|
||||||
|
get=check_kitsu_context,
|
||||||
|
options=set(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -256,7 +295,6 @@ class KITSU_property_group_window_manager(bpy.types.PropertyGroup):
|
|||||||
|
|
||||||
|
|
||||||
def _add_window_manager_props():
|
def _add_window_manager_props():
|
||||||
|
|
||||||
# Multi Edit Properties.
|
# Multi Edit Properties.
|
||||||
bpy.types.WindowManager.show_advanced = bpy.props.BoolProperty(
|
bpy.types.WindowManager.show_advanced = bpy.props.BoolProperty(
|
||||||
name="Show Advanced",
|
name="Show Advanced",
|
||||||
@ -337,9 +375,7 @@ def _calc_kitsu_frame_start(self):
|
|||||||
Calculates strip.kitsu_frame_start, little hack because it seems like we cant access the strip from a property group
|
Calculates strip.kitsu_frame_start, little hack because it seems like we cant access the strip from a property group
|
||||||
But we need acess to seqeuence properties.
|
But we need acess to seqeuence properties.
|
||||||
"""
|
"""
|
||||||
kitsu_frame_start = (
|
kitsu_frame_start = bkglobals.FRAME_START - self.kitsu.frame_start_offset
|
||||||
bkglobals.FRAME_START - self.kitsu.frame_start_offset
|
|
||||||
)
|
|
||||||
|
|
||||||
return int(kitsu_frame_start)
|
return int(kitsu_frame_start)
|
||||||
|
|
||||||
@ -350,7 +386,7 @@ def _calc_kitsu_frame_end(self):
|
|||||||
But we need acess to seqeuence properties.
|
But we need acess to seqeuence properties.
|
||||||
"""
|
"""
|
||||||
frame_start = _calc_kitsu_frame_start(self)
|
frame_start = _calc_kitsu_frame_start(self)
|
||||||
frame_end_final = (frame_start + (self.frame_final_duration - 1))
|
frame_end_final = frame_start + (self.frame_final_duration - 1)
|
||||||
return int(frame_end_final)
|
return int(frame_end_final)
|
||||||
|
|
||||||
|
|
||||||
@ -373,7 +409,6 @@ def update_sequence_colors_coll_prop(dummy: Any) -> None:
|
|||||||
|
|
||||||
# Append missing sequences to scene.kitsu.seqeuence_colors.
|
# Append missing sequences to scene.kitsu.seqeuence_colors.
|
||||||
for seq in sequences:
|
for seq in sequences:
|
||||||
|
|
||||||
if not seq.kitsu.sequence_id:
|
if not seq.kitsu.sequence_id:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -417,7 +452,6 @@ classes = [
|
|||||||
|
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
|
|
||||||
for cls in classes:
|
for cls in classes:
|
||||||
bpy.utils.register_class(cls)
|
bpy.utils.register_class(cls)
|
||||||
|
|
||||||
|
@ -50,10 +50,19 @@ def draw_error_invalid_playblast_root_dir(
|
|||||||
def draw_error_frame_range_outdated(
|
def draw_error_frame_range_outdated(
|
||||||
box: bpy.types.UILayout,
|
box: bpy.types.UILayout,
|
||||||
) -> bpy.types.UILayout:
|
) -> bpy.types.UILayout:
|
||||||
|
|
||||||
row = box.row(align=True)
|
row = box.row(align=True)
|
||||||
|
row.alert = True
|
||||||
row.label(text="Frame Range Outdated")
|
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_no_kitsu_context(
|
||||||
|
box: bpy.types.UILayout,
|
||||||
|
) -> bpy.types.UILayout:
|
||||||
|
row = box.row(align=True)
|
||||||
|
row.alert = True
|
||||||
|
row.label(text="File's Kitsu Context not found", icon="ERROR")
|
||||||
|
row.operator("kitsu.con_detect_context", icon="FILE_REFRESH")
|
||||||
|
|
||||||
|
|
||||||
def draw_error_invalid_render_preset_dir(
|
def draw_error_invalid_render_preset_dir(
|
||||||
@ -87,7 +96,6 @@ def draw_error_config_dir_not_exists(
|
|||||||
def draw_error_no_active_camera(
|
def draw_error_no_active_camera(
|
||||||
box: bpy.types.UILayout,
|
box: bpy.types.UILayout,
|
||||||
) -> bpy.types.UILayout:
|
) -> bpy.types.UILayout:
|
||||||
|
|
||||||
row = box.row(align=True)
|
row = box.row(align=True)
|
||||||
row.label(text=f"No active camera")
|
row.label(text=f"No active camera")
|
||||||
row.prop(bpy.context.scene, "camera", text="")
|
row.prop(bpy.context.scene, "camera", text="")
|
||||||
|
Loading…
Reference in New Issue
Block a user