diff --git a/openpype/hosts/tvpaint/plugins/publish/collect_instances.py b/openpype/hosts/tvpaint/plugins/publish/collect_instances.py index 68c142c005..0808dc06b1 100644 --- a/openpype/hosts/tvpaint/plugins/publish/collect_instances.py +++ b/openpype/hosts/tvpaint/plugins/publish/collect_instances.py @@ -34,8 +34,8 @@ class CollectInstances(pyblish.api.ContextPlugin): instance_data["name"] = name instance_data["label"] = "{} [{}-{}]".format( name, - context.data["sceneFrameStart"], - context.data["sceneFrameEnd"] + context.data["sceneMarkIn"] + 1, + context.data["sceneMarkOut"] + 1 ) active = instance_data.get("active", True) @@ -78,8 +78,8 @@ class CollectInstances(pyblish.api.ContextPlugin): if instance is None: continue - instance.data["frameStart"] = context.data["sceneFrameStart"] - instance.data["frameEnd"] = context.data["sceneFrameEnd"] + instance.data["frameStart"] = context.data["sceneMarkIn"] + 1 + instance.data["frameEnd"] = context.data["sceneMarkOut"] + 1 self.log.debug("Created instance: {}\n{}".format( instance, json.dumps(instance.data, indent=4) diff --git a/openpype/hosts/tvpaint/plugins/publish/collect_workfile_data.py b/openpype/hosts/tvpaint/plugins/publish/collect_workfile_data.py index e683c66ea9..4409413ff6 100644 --- a/openpype/hosts/tvpaint/plugins/publish/collect_workfile_data.py +++ b/openpype/hosts/tvpaint/plugins/publish/collect_workfile_data.py @@ -122,36 +122,26 @@ class CollectWorkfileData(pyblish.api.ContextPlugin): width = int(workfile_info_parts.pop(-1)) workfile_path = " ".join(workfile_info_parts).replace("\"", "") - frame_start, frame_end = self.collect_clip_frames() + # Marks return as "{frame - 1} {state} ", example "0 set". + result = lib.execute_george("tv_markin") + mark_in_frame, mark_in_state, _ = result.split(" ") + + result = lib.execute_george("tv_markout") + mark_out_frame, mark_out_state, _ = result.split(" ") + scene_data = { "currentFile": workfile_path, "sceneWidth": width, "sceneHeight": height, "scenePixelAspect": pixel_apsect, - "sceneFrameStart": frame_start, - "sceneFrameEnd": frame_end, "sceneFps": frame_rate, - "sceneFieldOrder": field_order + "sceneFieldOrder": field_order, + "sceneMarkIn": int(mark_in_frame), + "sceneMarkInState": mark_in_state == "set", + "sceneMarkOut": int(mark_out_frame), + "sceneMarkOutState": mark_out_state == "set" } self.log.debug( "Scene data: {}".format(json.dumps(scene_data, indent=4)) ) context.data.update(scene_data) - - def collect_clip_frames(self): - clip_info_str = lib.execute_george("tv_clipinfo") - self.log.debug("Clip info: {}".format(clip_info_str)) - clip_info_items = clip_info_str.split(" ") - # Color index - not used - clip_info_items.pop(-1) - clip_info_items.pop(-1) - - mark_out = int(clip_info_items.pop(-1)) - frame_end = mark_out + 1 - clip_info_items.pop(-1) - - mark_in = int(clip_info_items.pop(-1)) - frame_start = mark_in + 1 - clip_info_items.pop(-1) - - return frame_start, frame_end diff --git a/openpype/hosts/tvpaint/plugins/publish/validate_marks.py b/openpype/hosts/tvpaint/plugins/publish/validate_marks.py new file mode 100644 index 0000000000..73486d1005 --- /dev/null +++ b/openpype/hosts/tvpaint/plugins/publish/validate_marks.py @@ -0,0 +1,64 @@ +import json + +import pyblish.api +from avalon.tvpaint import lib + + +class ValidateMarksRepair(pyblish.api.Action): + """Repair the marks.""" + + label = "Repair" + icon = "wrench" + on = "failed" + + def process(self, context, plugin): + expected_data = ValidateMarks.get_expected_data(context) + + expected_data["markIn"] -= 1 + expected_data["markOut"] -= 1 + + lib.execute_george("tv_markin {} set".format(expected_data["markIn"])) + lib.execute_george( + "tv_markout {} set".format(expected_data["markOut"]) + ) + + +class ValidateMarks(pyblish.api.ContextPlugin): + """Validate mark in and out are enabled.""" + + label = "Validate Marks" + order = pyblish.api.ValidatorOrder + optional = True + actions = [ValidateMarksRepair] + + @staticmethod + def get_expected_data(context): + return { + "markIn": int(context.data["frameStart"]), + "markInState": True, + "markOut": int(context.data["frameEnd"]), + "markOutState": True + } + + def process(self, context): + current_data = { + "markIn": context.data["sceneMarkIn"] + 1, + "markInState": context.data["sceneMarkInState"], + "markOut": context.data["sceneMarkOut"] + 1, + "markOutState": context.data["sceneMarkOutState"] + } + expected_data = self.get_expected_data(context) + invalid = {} + for k in current_data.keys(): + if current_data[k] != expected_data[k]: + invalid[k] = { + "current": current_data[k], + "expected": expected_data[k] + } + + if invalid: + raise AssertionError( + "Marks does not match database:\n{}".format( + json.dumps(invalid, sort_keys=True, indent=4) + ) + ) diff --git a/openpype/hosts/tvpaint/plugins/publish/validate_project_settings.py b/openpype/hosts/tvpaint/plugins/publish/validate_project_settings.py index fead3393ae..84c03a9857 100644 --- a/openpype/hosts/tvpaint/plugins/publish/validate_project_settings.py +++ b/openpype/hosts/tvpaint/plugins/publish/validate_project_settings.py @@ -13,8 +13,6 @@ class ValidateProjectSettings(pyblish.api.ContextPlugin): def process(self, context): scene_data = { - "frameStart": context.data.get("sceneFrameStart"), - "frameEnd": context.data.get("sceneFrameEnd"), "fps": context.data.get("sceneFps"), "resolutionWidth": context.data.get("sceneWidth"), "resolutionHeight": context.data.get("sceneHeight"), diff --git a/openpype/settings/defaults/project_settings/tvpaint.json b/openpype/settings/defaults/project_settings/tvpaint.json index d4130c88be..a6c10b3809 100644 --- a/openpype/settings/defaults/project_settings/tvpaint.json +++ b/openpype/settings/defaults/project_settings/tvpaint.json @@ -1,6 +1,11 @@ { "publish": { - "ValidateMissingLayers": { + "ValidateProjectSettings": { + "enabled": true, + "optional": true, + "active": true + }, + "ValidateMarks": { "enabled": true, "optional": true, "active": true diff --git a/openpype/settings/entities/schemas/projects_schema/schema_project_tvpaint.json b/openpype/settings/entities/schemas/projects_schema/schema_project_tvpaint.json index b9fe26a57c..0a9e7139dd 100644 --- a/openpype/settings/entities/schemas/projects_schema/schema_project_tvpaint.json +++ b/openpype/settings/entities/schemas/projects_schema/schema_project_tvpaint.json @@ -17,8 +17,20 @@ "name": "template_publish_plugin", "template_data": [ { - "key": "ValidateMissingLayers", - "label": "ValidateMissingLayers" + "key": "ValidateProjectSettings", + "label": "ValidateProjectSettings", + "docstring": "Validate if FPS and Resolution match shot data" + } + ] + }, + { + "type": "schema_template", + "name": "template_publish_plugin", + "template_data": [ + { + "key": "ValidateMarks", + "label": "Validate MarkIn/Out", + "docstring": "Validate MarkIn/Out match Frame start/end on shot data" } ] }