diff --git a/openpype/hosts/max/plugins/create/create_tycache.py b/openpype/hosts/max/plugins/create/create_tycache.py index c48094028a..92d12e012f 100644 --- a/openpype/hosts/max/plugins/create/create_tycache.py +++ b/openpype/hosts/max/plugins/create/create_tycache.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- """Creator plugin for creating TyCache.""" from openpype.hosts.max.api import plugin -from openpype.lib import EnumDef class CreateTyCache(plugin.MaxCreator): @@ -10,24 +9,3 @@ class CreateTyCache(plugin.MaxCreator): label = "TyCache" family = "tycache" icon = "gear" - - def create(self, subset_name, instance_data, pre_create_data): - instance_data["tycache_type"] = pre_create_data.get( - "tycache_type") - super(CreateTyCache, self).create( - subset_name, - instance_data, - pre_create_data) - - def get_pre_create_attr_defs(self): - attrs = super(CreateTyCache, self).get_pre_create_attr_defs() - - tycache_format_enum = ["tycache", "tycachespline"] - - return attrs + [ - - EnumDef("tycache_type", - tycache_format_enum, - default="tycache", - label="TyCache Type") - ] diff --git a/openpype/hosts/max/plugins/publish/collect_tycache_attributes.py b/openpype/hosts/max/plugins/publish/collect_tycache_attributes.py index fa27a9a9d6..779b4c1b7e 100644 --- a/openpype/hosts/max/plugins/publish/collect_tycache_attributes.py +++ b/openpype/hosts/max/plugins/publish/collect_tycache_attributes.py @@ -14,22 +14,19 @@ class CollectTyCacheData(pyblish.api.InstancePlugin, families = ["tycache"] def process(self, instance): - all_tyc_attributes_dict = {} attr_values = self.get_attr_values_from_data(instance.data) - tycache_boolean_attributes = attr_values.get("all_tyc_attrs") - if tycache_boolean_attributes: - for attrs in tycache_boolean_attributes: - all_tyc_attributes_dict[attrs] = True - tyc_layer_attr = attr_values.get("tycache_layer") - if tyc_layer_attr: - all_tyc_attributes_dict["tycacheLayer"] = ( - tyc_layer_attr) - tyc_objname_attr = attr_values.get("tycache_objname") - if tyc_objname_attr: - all_tyc_attributes_dict["tycache_objname"] = ( - tyc_objname_attr) + attributes = {} + for attr_key in attr_values.get("tycacheAttributes", []): + attributes[attr_key] = True + + for key in ["tycacheLayer", "tycacheObjectName"]: + attributes[key] = attr_values.get(key, "") + + # Collect the selected channel data before exporting + instance.data["tyc_attrs"] = attributes self.log.debug( - f"Found tycache attributes: {all_tyc_attributes_dict}") + f"Found tycache attributes: {attributes}" + ) @classmethod def get_attribute_defs(cls): @@ -63,17 +60,17 @@ class CollectTyCacheData(pyblish.api.InstancePlugin, "tycacheChanMaterials", "tycacheCreateObjectIfNotCreated"] return [ - EnumDef("all_tyc_attrs", + EnumDef("tycacheAttributes", tyc_attr_enum, default=tyc_default_attrs, multiselection=True, label="TyCache Attributes"), - TextDef("tycache_layer", + TextDef("tycacheLayer", label="TyCache Layer", tooltip="Name of tycache layer", - default=""), - TextDef("tycache_objname", + default="$(tyFlowLayer)"), + TextDef("tycacheObjectName", label="TyCache Object Name", tooltip="TyCache Object Name", - default="") + default="$(tyFlowName)_tyCache") ] diff --git a/openpype/hosts/max/plugins/publish/extract_tycache.py b/openpype/hosts/max/plugins/publish/extract_tycache.py index a787080776..9262219b7a 100644 --- a/openpype/hosts/max/plugins/publish/extract_tycache.py +++ b/openpype/hosts/max/plugins/publish/extract_tycache.py @@ -13,9 +13,9 @@ class ExtractTyCache(publish.Extractor): Notes: - TyCache only works for TyFlow Pro Plugin. - Args: - self.export_particle(): sets up all job arguments for attributes - to be exported in MAXscript + Methods: + self.get_export_particles_job_args(): sets up all job arguments + for attributes to be exported in MAXscript self.get_operators(): get the export_particle operator @@ -30,7 +30,7 @@ class ExtractTyCache(publish.Extractor): def process(self, instance): # TODO: let user decide the param - start = int(instance.context.data.get("frameStart")) + start = int(instance.context.data["frameStart"]) end = int(instance.context.data.get("frameEnd")) self.log.info("Extracting Tycache...") @@ -42,17 +42,11 @@ class ExtractTyCache(publish.Extractor): with maintained_selection(): job_args = None - has_tyc_spline = ( - True - if instance.data["tycache_type"] == "tycachespline" - else False - ) if instance.data["tycache_type"] == "tycache": - job_args = self.export_particle( + job_args = self.get_export_particles_job_args( instance.data["members"], start, end, path, - additional_attributes, - tycache_spline_enabled=has_tyc_spline) + additional_attributes) for job in job_args: rt.Execute(job) representations = instance.data.setdefault("representations", []) @@ -66,7 +60,7 @@ class ExtractTyCache(publish.Extractor): self.log.info(f"Extracted instance '{instance.name}' to: {filenames}") # Get the tyMesh filename for extraction - mesh_filename = "{}__tyMesh.tyc".format(instance.name) + mesh_filename = f"{instance.name}__tyMesh.tyc" mesh_repres = { 'name': 'tyMesh', 'ext': 'tyc', @@ -90,7 +84,7 @@ class ExtractTyCache(publish.Extractor): e.g. tycacheMain__tyPart_00000.tyc Args: - instance (str): instance. + instance (pyblish.api.Instance): instance. start_frame (int): Start frame. end_frame (int): End frame. @@ -101,13 +95,12 @@ class ExtractTyCache(publish.Extractor): filenames = [] # should we include frame 0 ? for frame in range(int(start_frame), int(end_frame) + 1): - filename = "{}__tyPart_{:05}.tyc".format(instance.name, frame) + filename = f"{instance.name}__tyPart_{frame:05}.tyc" filenames.append(filename) return filenames - def export_particle(self, members, start, end, - filepath, additional_attributes, - tycache_spline_enabled=False): + def get_export_particles_job_args(self, members, start, end, + filepath, additional_attributes): """Sets up all job arguments for attributes. Those attributes are to be exported in MAX Script. @@ -117,6 +110,8 @@ class ExtractTyCache(publish.Extractor): start (int): Start frame. end (int): End frame. filepath (str): Output path of the TyCache file. + additional_attributes (dict): channel attributes data + which needed to be exported Returns: list of arguments for MAX Script. @@ -125,12 +120,7 @@ class ExtractTyCache(publish.Extractor): job_args = [] opt_list = self.get_operators(members) for operator in opt_list: - if tycache_spline_enabled: - export_mode = f'{operator}.exportMode=3' - job_args.append(export_mode) - else: - export_mode = f'{operator}.exportMode=2' - job_args.append(export_mode) + job_args.append(f"{operator}.exportMode=2") start_frame = f"{operator}.frameStart={start}" job_args.append(start_frame) end_frame = f"{operator}.frameEnd={end}" @@ -192,6 +182,7 @@ class ExtractTyCache(publish.Extractor): if isinstance(value, bool): tyc_attribute = f"{operator}.{key}=True" elif isinstance(value, str): - tyc_attribute = f"{operator}.{key}={value}" + tyc_attribute = f'{operator}.{key}="{value}"' additional_args.append(tyc_attribute) + self.log.debug(additional_args) return additional_args diff --git a/openpype/hosts/max/plugins/publish/validate_tyflow_data.py b/openpype/hosts/max/plugins/publish/validate_tyflow_data.py index a359100e6e..4b2bf975ee 100644 --- a/openpype/hosts/max/plugins/publish/validate_tyflow_data.py +++ b/openpype/hosts/max/plugins/publish/validate_tyflow_data.py @@ -40,7 +40,7 @@ class ValidateTyFlowData(pyblish.api.InstancePlugin): and editable mesh(es) Args: - instance (str): instance node + instance (pyblish.api.Instance): instance Returns: invalid(list): list of invalid nodes which are not