Bases: InstancePlugin
, OptionalPyblishPluginMixin
Ensure that the tracks aligns with the clipIn/clipOut value in database.
Source code in client/ayon_unreal/plugins/publish/validate_frame_range.py
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84 | class ValidateFrameRange(pyblish.api.InstancePlugin,
OptionalPyblishPluginMixin):
"""Ensure that the tracks aligns with the clipIn/clipOut
value in database.
"""
order = pyblish.api.ValidatorOrder
label = "Validate Frame Range"
hosts = ['unreal']
families = ["camera"]
actions = [RepairAction]
def process(self, instance):
if not self.is_active(instance.data):
self.log.debug("Skipping Validate Frame Range...")
return
inst_clip_in = instance.data.get("clipIn")
inst_clip_out = instance.data.get("clipOut")
if inst_clip_in is None or inst_clip_out is None:
raise KnownPublishError(
"Missing clip In and clip Out values on "
"instance to to validate."
)
clip_in_handle, clip_out_handle = get_frame_range_from_folder_attributes(
instance.data["folderEntity"])
errors = []
if inst_clip_in != clip_in_handle:
errors.append(
f"Clip-In value ({inst_clip_in}) on instance does not match " # noqa
f"with the Clip-In value ({clip_in_handle}) set on the folder attributes. ") # noqa
if inst_clip_out != clip_out_handle:
errors.append(
f"Clip-Out value ({inst_clip_out}) on instance does not match "
f"with the Clip-Out value ({clip_out_handle}) "
"from the folder attributes. ")
if errors:
bullet_point_errors = "\n".join(
"- {}".format(err) for err in errors
)
report = (
"Clip In/Out settings are incorrect.\n\n"
f"{bullet_point_errors}\n\n"
"You can use repair action to fix it."
)
raise PublishValidationError(report, title="Frame Range incorrect")
@classmethod
def repair(cls, instance):
clip_in_handle, clip_out_handle = get_frame_range_from_folder_attributes(
instance.data["folderEntity"])
for member in instance.data.get('members'):
ar = unreal.AssetRegistryHelpers.get_asset_registry()
data = ar.get_asset_by_object_path(member)
is_level_sequence = (
data.asset_class_path.asset_name == "LevelSequence")
if is_level_sequence:
sequence = data.get_asset()
camera_tracks = get_camera_tracks(sequence)
if not camera_tracks:
return sequence.get_playback_start(), sequence.get_playback_end()
for camera_track in camera_tracks:
sections = camera_track.get_sections()
for section in sections:
section.set_range(clip_in_handle, clip_out_handle)
|