From b3b49440402c5f7787c7f47b0aeebff52bd0a351 Mon Sep 17 00:00:00 2001 From: Cyprien CAILLOT Date: Wed, 11 Sep 2024 15:22:46 +0200 Subject: [PATCH] Enhancement: Add custom start frame for tvpaint start frame validator --- .../publish/help/validate_start_frame.xml | 6 +-- .../plugins/publish/validate_start_frame.py | 12 +++--- .../defaults/project_settings/tvpaint.json | 3 +- .../schema_project_tvpaint.json | 40 ++++++++++++++----- .../server/settings/publish_plugins.py | 3 +- 5 files changed, 45 insertions(+), 19 deletions(-) diff --git a/openpype/hosts/tvpaint/plugins/publish/help/validate_start_frame.xml b/openpype/hosts/tvpaint/plugins/publish/help/validate_start_frame.xml index 9052abf66c3..f373e1a926b 100644 --- a/openpype/hosts/tvpaint/plugins/publish/help/validate_start_frame.xml +++ b/openpype/hosts/tvpaint/plugins/publish/help/validate_start_frame.xml @@ -2,13 +2,13 @@ First frame -## MarkIn is not set to 0 +## MarkIn is not set to {start_frame_expected} -MarkIn in your scene must start from 0 fram index but MarkIn is set to {current_start_frame}. +MarkIn in your scene must start from frame {start_frame_expected} but MarkIn is set to {current_start_frame}. ### How to repair? -You can modify MarkIn manually or hit the "Repair" button on the right which will change MarkIn to 0 (does not change MarkOut). +You can modify MarkIn manually or hit the "Repair" button on the right which will change MarkIn to {start_frame_expected} (does not change MarkOut). diff --git a/openpype/hosts/tvpaint/plugins/publish/validate_start_frame.py b/openpype/hosts/tvpaint/plugins/publish/validate_start_frame.py index 229ccfcd18f..0c2e23f49a1 100644 --- a/openpype/hosts/tvpaint/plugins/publish/validate_start_frame.py +++ b/openpype/hosts/tvpaint/plugins/publish/validate_start_frame.py @@ -14,7 +14,7 @@ class RepairStartFrame(pyblish.api.Action): on = "failed" def process(self, context, plugin): - execute_george("tv_startframe 0") + execute_george(f"tv_startframe {plugin.start_frame}") class ValidateStartFrame( @@ -28,19 +28,21 @@ class ValidateStartFrame( hosts = ["tvpaint"] actions = [RepairStartFrame] optional = True + start_frame = 0 def process(self, context): if not self.is_active(context.data): return - start_frame = execute_george("tv_startframe") - if start_frame == 0: + scene_start_frame = execute_george("tv_startframe") + if scene_start_frame == self.start_frame: return raise PublishXmlValidationError( self, - "Start frame has to be frame 0.", + f"Start frame has to be frame {self.start_frame}.", formatting_data={ - "current_start_frame": start_frame + "start_frame_expected": self.start_frame, + "current_start_frame": scene_start_frame } ) diff --git a/openpype/settings/defaults/project_settings/tvpaint.json b/openpype/settings/defaults/project_settings/tvpaint.json index d03b8b7227b..39148b466af 100644 --- a/openpype/settings/defaults/project_settings/tvpaint.json +++ b/openpype/settings/defaults/project_settings/tvpaint.json @@ -75,7 +75,8 @@ "ValidateStartFrame": { "enabled": false, "optional": true, - "active": true + "active": true, + "start_frame": 0 }, "ValidateAssetName": { "enabled": 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 5b2647bc6d6..629540091e2 100644 --- a/openpype/settings/entities/schemas/projects_schema/schema_project_tvpaint.json +++ b/openpype/settings/entities/schemas/projects_schema/schema_project_tvpaint.json @@ -299,15 +299,37 @@ ] }, { - "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": "dict", + "key": "ValidateStartFrame", + "label": "Validate Start Frame", + "is_group": true, + "checkbox_key": "enabled", + "children": [ + { + "type": "boolean", + "key": "enabled", + "label": "Enabled" + }, + { + "type": "boolean", + "key": "optional", + "label": "Optional" + }, + { + "type": "boolean", + "key": "active", + "label": "Active" + }, + { + "type": "label", + "label": "Validate start frame of scene is set to the value configured below." + }, + { + "type": "text", + "key": "start_frame", + "label": "Start frame" + } + ] }, { "type": "schema_template", diff --git a/server_addon/tvpaint/server/settings/publish_plugins.py b/server_addon/tvpaint/server/settings/publish_plugins.py index 0623524c924..c75ad7b32a4 100644 --- a/server_addon/tvpaint/server/settings/publish_plugins.py +++ b/server_addon/tvpaint/server/settings/publish_plugins.py @@ -115,7 +115,8 @@ class LoadPluginsModel(BaseSettingsModel): "ValidateStartFrame": { "enabled": False, "optional": True, - "active": True + "active": True, + "start_frame": 0 }, "ValidateAssetName": { "enabled": True,