From 404a4dedfcfd798cbcdbab8dc3637d36b5e059e8 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Fri, 20 Oct 2023 11:20:58 +0800 Subject: [PATCH] clean up the code across the tycache families --- .../hosts/max/plugins/load/load_tycache.py | 2 +- .../max/plugins/publish/extract_tycache.py | 6 ++--- .../plugins/publish/validate_tyflow_data.py | 25 ++++++++----------- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/openpype/hosts/max/plugins/load/load_tycache.py b/openpype/hosts/max/plugins/load/load_tycache.py index f878ed9f1c..ff9598b33f 100644 --- a/openpype/hosts/max/plugins/load/load_tycache.py +++ b/openpype/hosts/max/plugins/load/load_tycache.py @@ -25,7 +25,7 @@ class TyCacheLoader(load.LoaderPlugin): def load(self, context, name=None, namespace=None, data=None): """Load tyCache""" from pymxs import runtime as rt - filepath = os.path.normpath(self.filepath_from_context(context)) + filepath = self.filepath_from_context(context) obj = rt.tyCache() obj.filename = filepath diff --git a/openpype/hosts/max/plugins/publish/extract_tycache.py b/openpype/hosts/max/plugins/publish/extract_tycache.py index d9d7c17cff..baed8a9e44 100644 --- a/openpype/hosts/max/plugins/publish/extract_tycache.py +++ b/openpype/hosts/max/plugins/publish/extract_tycache.py @@ -8,8 +8,7 @@ from openpype.pipeline import publish class ExtractTyCache(publish.Extractor): - """ - Extract tycache format with tyFlow operators. + """Extract tycache format with tyFlow operators. Notes: - TyCache only works for TyFlow Pro Plugin. @@ -89,7 +88,6 @@ class ExtractTyCache(publish.Extractor): """ filenames = [] - # should we include frame 0 ? for frame in range(int(start_frame), int(end_frame) + 1): filename = f"{instance.name}__tyPart_{frame:05}.tyc" filenames.append(filename) @@ -146,7 +144,7 @@ class ExtractTyCache(publish.Extractor): opt_list = [] for member in members: obj = member.baseobject - # TODO: to see if it can be used maxscript instead + # TODO: see if it can use maxscript instead anim_names = rt.GetSubAnimNames(obj) for anim_name in anim_names: sub_anim = rt.GetSubAnim(obj, anim_name) diff --git a/openpype/hosts/max/plugins/publish/validate_tyflow_data.py b/openpype/hosts/max/plugins/publish/validate_tyflow_data.py index 67c35ec01c..c0f29422ec 100644 --- a/openpype/hosts/max/plugins/publish/validate_tyflow_data.py +++ b/openpype/hosts/max/plugins/publish/validate_tyflow_data.py @@ -4,8 +4,7 @@ from pymxs import runtime as rt class ValidateTyFlowData(pyblish.api.InstancePlugin): - """Validate that TyFlow plugins or - relevant operators being set correctly.""" + """Validate TyFlow plugins or relevant operators are set correctly.""" order = pyblish.api.ValidatorOrder families = ["pointcloud", "tycache"] @@ -31,9 +30,9 @@ class ValidateTyFlowData(pyblish.api.InstancePlugin): if invalid_object or invalid_operator: raise PublishValidationError( "issues occurred", - description="Container should only include tyFlow object\n " - "and tyflow operator 'Export Particle' should be in \n" - "the tyFlow editor") + description="Container should only include tyFlow object " + "and tyflow operator 'Export Particle' should be in " + "the tyFlow editor.") def get_tyflow_object(self, instance): """Get the nodes which are not tyFlow object(s) @@ -43,19 +42,17 @@ class ValidateTyFlowData(pyblish.api.InstancePlugin): instance (pyblish.api.Instance): instance Returns: - invalid(list): list of invalid nodes which are not - tyFlow object(s) and editable mesh(es). + list: invalid nodes which are not tyFlow + object(s) and editable mesh(es). """ - invalid = [] container = instance.data["instance_node"] self.log.debug(f"Validating tyFlow container for {container}") - selection_list = instance.data["members"] - for sel in selection_list: - if rt.ClassOf(sel) not in [rt.tyFlow, rt.Editable_Mesh]: - invalid.append(sel) - - return invalid + allowed_classes = [rt.tyFlow, rt.Editable_Mesh] + return [ + member for member in instance.data["members"] + if rt.ClassOf(member) not in allowed_classes + ] def get_tyflow_operator(self, instance): """Check if the Export Particle Operators in the node