diff --git a/openpype/hosts/tvpaint/api/__init__.py b/openpype/hosts/tvpaint/api/__init__.py index bd9ef51a767..57a03d38b76 100644 --- a/openpype/hosts/tvpaint/api/__init__.py +++ b/openpype/hosts/tvpaint/api/__init__.py @@ -19,6 +19,10 @@ def on_instance_toggle(instance, old_value, new_value): + # Review may not have real instance in wokrfile metadata + if not instance.data.get("uuid"): + return + instance_id = instance.data["uuid"] found_idx = None current_instances = pipeline.list_instances() diff --git a/openpype/hosts/tvpaint/plugins/create/create_review.py b/openpype/hosts/tvpaint/plugins/create/create_review.py deleted file mode 100644 index 88b039c8e4c..00000000000 --- a/openpype/hosts/tvpaint/plugins/create/create_review.py +++ /dev/null @@ -1,19 +0,0 @@ -from avalon.tvpaint import pipeline -from openpype.hosts.tvpaint.api import plugin - - -class CreateReview(plugin.Creator): - """Review for global review of all layers.""" - name = "review" - label = "Review" - family = "review" - icon = "cube" - defaults = ["Main"] - - def process(self): - instances = pipeline.list_instances() - for instance in instances: - if instance["family"] == self.family: - self.log.info("Review family is already Created.") - return - super(CreateReview, self).process() diff --git a/openpype/hosts/tvpaint/plugins/publish/collect_instances.py b/openpype/hosts/tvpaint/plugins/publish/collect_instances.py index 27bd8e9edef..61cf7eb7806 100644 --- a/openpype/hosts/tvpaint/plugins/publish/collect_instances.py +++ b/openpype/hosts/tvpaint/plugins/publish/collect_instances.py @@ -17,6 +17,20 @@ def process(self, context): json.dumps(workfile_instances, indent=4) )) + # Backwards compatibility for workfiles that already have review + # instance in metadata. + review_instance_exist = False + for instance_data in workfile_instances: + if instance_data["family"] == "review": + review_instance_exist = True + break + + # Fake review instance if review was not found in metadata families + if not review_instance_exist: + workfile_instances.append( + self._create_review_instance_data(context) + ) + for instance_data in workfile_instances: instance_data["fps"] = context.data["sceneFps"] @@ -90,6 +104,16 @@ def process(self, context): instance, json.dumps(instance.data, indent=4) )) + def _create_review_instance_data(self, context): + """Fake review instance data.""" + + return { + "family": "review", + "asset": context.data["workfile_context"]["asset"], + # Dummy subset name + "subset": "reviewMain" + } + def create_render_layer_instance(self, context, instance_data): name = instance_data["name"] # Change label