From af87fdf657adb7ca5dd6f34bdd41335dc2b9efa7 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 20 Dec 2023 21:31:19 +0800 Subject: [PATCH] the resourceDir for texture also supports without image search path --- .../maya/plugins/publish/collect_yeti_rig.py | 29 ++++++++----------- .../maya/plugins/publish/extract_yeti_rig.py | 16 ++++++---- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/collect_yeti_rig.py b/openpype/hosts/maya/plugins/publish/collect_yeti_rig.py index 835934e1bf..d67c51b895 100644 --- a/openpype/hosts/maya/plugins/publish/collect_yeti_rig.py +++ b/openpype/hosts/maya/plugins/publish/collect_yeti_rig.py @@ -124,19 +124,19 @@ class CollectYetiRig(pyblish.api.InstancePlugin): image_search_paths = [p for p in image_search_paths.split(os.path.pathsep) if p] - # find all ${TOKEN} tokens and replace them with $TOKEN env. variable - image_search_paths = self._replace_tokens(image_search_paths) + # find all ${TOKEN} tokens and replace them with $TOKEN env. variable + image_search_paths = self._replace_tokens(image_search_paths) - # List all related textures - texture_nodes = cmds.pgYetiGraph( - node, listNodes=True, type="texture") - texture_filenames = [ - cmds.pgYetiGraph( - node, node=texture_node, - param="file_name", getParamValue=True) - for texture_node in texture_nodes - ] - self.log.debug("Found %i texture(s)" % len(texture_filenames)) + # List all related textures + texture_nodes = cmds.pgYetiGraph( + node, listNodes=True, type="texture") + texture_filenames = [ + cmds.pgYetiGraph( + node, node=texture_node, + param="file_name", getParamValue=True) + for texture_node in texture_nodes + ] + self.log.debug("Found %i texture(s)" % len(texture_filenames)) # Get all reference nodes reference_nodes = cmds.pgYetiGraph(node, @@ -144,11 +144,6 @@ class CollectYetiRig(pyblish.api.InstancePlugin): type="reference") self.log.debug("Found %i reference node(s)" % len(reference_nodes)) - if texture_filenames and not image_search_paths: - raise ValueError("pgYetiMaya node '%s' is missing the path to the " - "files in the 'imageSearchPath " - "atttribute'" % node) - # Collect all texture files # find all ${TOKEN} tokens and replace them with $TOKEN env. variable texture_filenames = self._replace_tokens(texture_filenames) diff --git a/openpype/hosts/maya/plugins/publish/extract_yeti_rig.py b/openpype/hosts/maya/plugins/publish/extract_yeti_rig.py index da67cb911f..a76d15d43e 100644 --- a/openpype/hosts/maya/plugins/publish/extract_yeti_rig.py +++ b/openpype/hosts/maya/plugins/publish/extract_yeti_rig.py @@ -142,12 +142,18 @@ class ExtractYetiRig(publish.Extractor): instance.data['transfers'] = [] for resource in instance.data.get('resources', []): - for file in resource['files']: - src = file - dst = os.path.join(image_search_path, os.path.basename(file)) - instance.data['transfers'].append([src, dst]) + if resource["files"]: + for file in resource['files']: + src = file + dst = os.path.join(image_search_path, os.path.basename(file)) + instance.data['transfers'].append([src, dst]) + else: + for file in resource['source']: + src = file if os.path.isabs(file) else os.path.abspath(file) + dst = os.path.join(image_search_path, os.path.basename(file)) + instance.data['transfers'].append([src, dst]) - self.log.debug("adding transfer {} -> {}". format(src, dst)) + self.log.debug("adding transfer {} -> {}". format(src, dst)) # Ensure the imageSearchPath is being remapped to the publish folder attr_value = {"%s.imageSearchPath" % n: str(image_search_path) for