diff --git a/pype/plugins/tvpaint/create/create_beauty.py b/pype/plugins/tvpaint/create/create_beauty.py index aaa51f156e..f68365a2d4 100644 --- a/pype/plugins/tvpaint/create/create_beauty.py +++ b/pype/plugins/tvpaint/create/create_beauty.py @@ -21,22 +21,25 @@ class CreateBeauty(pipeline.TVPaintCreator): def process(self): self.log.debug("Query data from workfile.") instances = pipeline.list_instances() - groups_data = lib.groups_data() layers_data = lib.layers_data() self.log.debug("Checking for selection groups.") + # Collect group ids from selection group_ids = set() for layer in layers_data: if layer["selected"]: group_ids.add(layer["group_id"]) + # Raise if there is no selection if not group_ids: raise AssertionError("Nothing is selected.") + # This creator should run only on one group if len(group_ids) > 1: raise AssertionError("More than one group is in selection.") group_id = tuple(group_ids)[0] + # If group id is `0` it is `default` group which is invalid if group_id == 0: raise AssertionError( "Selection is not in group. Can't mark selection as Beauty." @@ -46,11 +49,12 @@ class CreateBeauty(pipeline.TVPaintCreator): self.data["group_id"] = group_id family = self.data["family"] - # Is this right way how to get name? + # Extract entered name name = self.data["subset"][len(family):] self.log.info(f"Extracted name from subset name \"{name}\".") self.data["name"] = name + # Change subset name by template subset_name = self.subset_template.format(**{ "family": self.family, # Should be task name capitalized? @@ -61,6 +65,7 @@ class CreateBeauty(pipeline.TVPaintCreator): self.log.info(f"New subset name \"{subset_name}\".") self.data["subset"] = subset_name + # Check for instances for same group existing_instance = None existing_instance_idx = None for idx, instance in enumerate(instances): @@ -90,12 +95,17 @@ class CreateBeauty(pipeline.TVPaintCreator): self.log.info("Group rename function is turned off. Skipping") return + self.log.debug("Querying groups data from workfile.") + groups_data = lib.groups_data() + self.log.debug("Changing name of the group.") selected_group = None for group_data in groups_data: if group_data["id"] == group_id: selected_group = group_data + # Rename TVPaint group (keep color same) + # - groups can't contain spaces new_group_name = name.replace(" ", "_") rename_script = self.rename_script_template.format( clip_id=selected_group["clip_id"], diff --git a/pype/plugins/tvpaint/create/create_render_pass.py b/pype/plugins/tvpaint/create/create_render_pass.py index 37d7c501f9..a28348f46a 100644 --- a/pype/plugins/tvpaint/create/create_render_pass.py +++ b/pype/plugins/tvpaint/create/create_render_pass.py @@ -23,6 +23,7 @@ class CreateRenderPass(pipeline.TVPaintCreator): layers_data = lib.layers_data() self.log.debug("Checking selection.") + # Get all selected layers and their group ids group_ids = set() selected_layers = [] for layer in layers_data: @@ -30,15 +31,18 @@ class CreateRenderPass(pipeline.TVPaintCreator): selected_layers.append(layer) group_ids.add(layer["group_id"]) + # Raise if nothing is selected if not selected_layers: raise AssertionError("Nothing is selected.") + # Raise if layers from multiple groups are selected if len(group_ids) != 1: raise AssertionError("More than one group is in selection.") group_id = tuple(group_ids)[0] self.log.debug(f"Selected group id is \"{group_id}\".") + # Find beauty instance for selected layers beauty_instance = None for instance in instances: if ( @@ -48,9 +52,11 @@ class CreateRenderPass(pipeline.TVPaintCreator): beauty_instance = instance break + # Beauty is required for this creator so raise if was not found if beauty_instance is None: raise AssertionError("Beauty pass does not exist yet.") + # Extract entered name family = self.data["family"] name = self.data["subset"] # Is this right way how to get name? @@ -60,6 +66,7 @@ class CreateRenderPass(pipeline.TVPaintCreator): self.data["group_id"] = group_id self.data["name"] = name + # Collect selected layer ids to be stored into instance layer_ids = [layer["id"] for layer in selected_layers] self.data["layer_ids"] = layer_ids @@ -69,16 +76,19 @@ class CreateRenderPass(pipeline.TVPaintCreator): f"beauty instance \"{beauty_subset_name}\"." ) + # Beauty instance subset name should if not beauty_subset_name.endswith(self.beauty_pass_name): raise AssertionError( "BUG: Beauty subset name does not end with \"{}\"".format( self.beauty_pass_name ) ) + # Replace `beauty` in beauty's subset name with entered name subset_name = beauty_subset_name[:-len(self.beauty_pass_name)] + name self.data["subset"] = subset_name self.log.info(f"New subset name is \"{subset_name}\".") + # Check if same instance already exists existing_instance = None existing_instance_idx = None for idx, instance in enumerate(instances):