From d2fa34b52b442f0b4f81754d8ded322fb8f6c6b0 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 21 Jul 2021 17:52:01 +0200 Subject: [PATCH 1/5] store scene frame start to context --- openpype/hosts/tvpaint/plugins/publish/collect_workfile_data.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openpype/hosts/tvpaint/plugins/publish/collect_workfile_data.py b/openpype/hosts/tvpaint/plugins/publish/collect_workfile_data.py index d8bb03f541..79cc01740a 100644 --- a/openpype/hosts/tvpaint/plugins/publish/collect_workfile_data.py +++ b/openpype/hosts/tvpaint/plugins/publish/collect_workfile_data.py @@ -155,6 +155,7 @@ class CollectWorkfileData(pyblish.api.ContextPlugin): "sceneMarkInState": mark_in_state == "set", "sceneMarkOut": int(mark_out_frame), "sceneMarkOutState": mark_out_state == "set", + "sceneStartFrame": int(lib.execute_george("tv_startframe")), "sceneBgColor": self._get_bg_color() } self.log.debug( From bdd065a840418410132c8f12a71a17466946260a Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 21 Jul 2021 17:53:14 +0200 Subject: [PATCH 2/5] use scene start frame as an offset --- .../hosts/tvpaint/plugins/publish/extract_sequence.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/openpype/hosts/tvpaint/plugins/publish/extract_sequence.py b/openpype/hosts/tvpaint/plugins/publish/extract_sequence.py index 536df2adb0..472d57db36 100644 --- a/openpype/hosts/tvpaint/plugins/publish/extract_sequence.py +++ b/openpype/hosts/tvpaint/plugins/publish/extract_sequence.py @@ -49,6 +49,14 @@ class ExtractSequence(pyblish.api.Extractor): family_lowered = instance.data["family"].lower() mark_in = instance.context.data["sceneMarkIn"] mark_out = instance.context.data["sceneMarkOut"] + + # Scene start frame offsets the output files, so we need to offset the + # marks. + scene_start_frame = instance.context.data["sceneStartFrame"] + difference = scene_start_frame - mark_in + mark_in += difference + mark_out += difference + # Frame start/end may be stored as float frame_start = int(instance.data["frameStart"]) frame_end = int(instance.data["frameEnd"]) From f079508c20fb86b7acba414b2ffc038c61f759bd Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 21 Jul 2021 17:53:22 +0200 Subject: [PATCH 3/5] fix variable name --- openpype/hosts/tvpaint/plugins/publish/extract_sequence.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/hosts/tvpaint/plugins/publish/extract_sequence.py b/openpype/hosts/tvpaint/plugins/publish/extract_sequence.py index 472d57db36..1df7512588 100644 --- a/openpype/hosts/tvpaint/plugins/publish/extract_sequence.py +++ b/openpype/hosts/tvpaint/plugins/publish/extract_sequence.py @@ -106,7 +106,7 @@ class ExtractSequence(pyblish.api.Extractor): self.log.warning(( "Lowering representation range to {} frames." " Changed frame end {} -> {}" - ).format(output_range + 1, mark_out, new_mark_out)) + ).format(output_range + 1, mark_out, new_output_frame_end)) output_frame_end = new_output_frame_end # ------------------------------------------------------------------- From 2b38639f9ef427b56fe9cc26f29634fd50d68fa7 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 21 Jul 2021 17:58:15 +0200 Subject: [PATCH 4/5] added validator for checking start frame --- .../plugins/publish/validate_start_frame.py | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 openpype/hosts/tvpaint/plugins/publish/validate_start_frame.py diff --git a/openpype/hosts/tvpaint/plugins/publish/validate_start_frame.py b/openpype/hosts/tvpaint/plugins/publish/validate_start_frame.py new file mode 100644 index 0000000000..d769d47736 --- /dev/null +++ b/openpype/hosts/tvpaint/plugins/publish/validate_start_frame.py @@ -0,0 +1,27 @@ +import pyblish.api +from avalon.tvpaint import lib + + +class RepairStartFrame(pyblish.api.Action): + """Repair start frame.""" + + label = "Repair" + icon = "wrench" + on = "failed" + + def process(self, context, plugin): + lib.execute_george("tv_startframe 0") + + +class ValidateStartFrame(pyblish.api.ContextPlugin): + """Validate start frame being at frame 0.""" + + label = "Validate Start Frame" + order = pyblish.api.ValidatorOrder + hosts = ["tvpaint"] + actions = [RepairStartFrame] + optional = True + + def process(self, context): + start_frame = lib.execute_george("tv_startframe") + assert int(start_frame) == 0, "Start frame has to be frame 0." From 4e9ee047ae573c7cfe7c97bc6e43e6e7bd51630d Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 21 Jul 2021 17:58:22 +0200 Subject: [PATCH 5/5] added settings for new validator which is turned off by default --- .../settings/defaults/project_settings/tvpaint.json | 5 +++++ .../projects_schema/schema_project_tvpaint.json | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/openpype/settings/defaults/project_settings/tvpaint.json b/openpype/settings/defaults/project_settings/tvpaint.json index 763802a73f..47f486aa98 100644 --- a/openpype/settings/defaults/project_settings/tvpaint.json +++ b/openpype/settings/defaults/project_settings/tvpaint.json @@ -18,6 +18,11 @@ "optional": true, "active": true }, + "ValidateStartFrame": { + "enabled": false, + "optional": true, + "active": true + }, "ValidateAssetName": { "enabled": true, "optional": 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 67aa4b0a06..368141813f 100644 --- a/openpype/settings/entities/schemas/projects_schema/schema_project_tvpaint.json +++ b/openpype/settings/entities/schemas/projects_schema/schema_project_tvpaint.json @@ -52,6 +52,17 @@ } ] }, + { + "type": "schema_template", + "name": "template_publish_plugin", + "template_data": [ + { + "key": "ValidateStartFrame", + "label": "Validate Scene Start Frame", + "docstring": "Validate first frame of scene is set to '0'." + } + ] + }, { "type": "schema_template", "name": "template_publish_plugin",