mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-27 06:12:19 +01:00
collect reference files, extended docstrings
This commit is contained in:
parent
55dd74ddd5
commit
d8030186cd
1 changed files with 49 additions and 10 deletions
|
|
@ -64,10 +64,9 @@ class CollectYetiRig(pyblish.api.InstancePlugin):
|
|||
|
||||
# Collect any textures if used
|
||||
yeti_resources = []
|
||||
yeti_nodes = cmds.ls(instance[:], type="pgYetiMaya")
|
||||
yeti_nodes = cmds.ls(instance[:], type="pgYetiMaya", long=True)
|
||||
for node in yeti_nodes:
|
||||
# Get Yeti resources (textures)
|
||||
# TODO: referenced files in Yeti Graph
|
||||
resources = self.get_yeti_resources(node)
|
||||
yeti_resources.extend(resources)
|
||||
|
||||
|
|
@ -80,11 +79,16 @@ class CollectYetiRig(pyblish.api.InstancePlugin):
|
|||
instance.data["endFrame"] = 1
|
||||
|
||||
def get_yeti_resources(self, node):
|
||||
"""Get all texture file paths
|
||||
"""Get all resource file paths
|
||||
|
||||
If a texture is a sequence it gathers all sibling files to ensure
|
||||
the texture sequence is complete.
|
||||
|
||||
References can be used in the Yeti graph, this means that it is
|
||||
possible to load previously caches files. The information will need
|
||||
to be stored and, if the file not publish, copied to the resource
|
||||
folder.
|
||||
|
||||
Args:
|
||||
node (str): node name of the pgYetiMaya node
|
||||
|
||||
|
|
@ -93,15 +97,25 @@ class CollectYetiRig(pyblish.api.InstancePlugin):
|
|||
"""
|
||||
resources = []
|
||||
image_search_path = cmds.getAttr("{}.imageSearchPath".format(node))
|
||||
|
||||
# List all related textures
|
||||
texture_filenames = cmds.pgYetiCommand(node, listTextures=True)
|
||||
self.log.info("Found %i texture(s)" % len(texture_filenames))
|
||||
|
||||
# Get all reference nodes
|
||||
reference_nodes = cmds.pgYetiGraph(node,
|
||||
listNodes=True,
|
||||
type="reference")
|
||||
self.log.info("Found %i reference node(s)" % len(reference_nodes))
|
||||
|
||||
if texture_filenames and not image_search_path:
|
||||
raise ValueError("pgYetiMaya node '%s' is missing the path to the "
|
||||
"files in the 'imageSearchPath "
|
||||
"atttribute'" % node)
|
||||
|
||||
# Collect all texture files
|
||||
for texture in texture_filenames:
|
||||
node_resources = {"files": [], "source": texture, "node": node}
|
||||
item = {"files": [], "source": texture, "node": node}
|
||||
texture_filepath = os.path.join(image_search_path, texture)
|
||||
if len(texture.split(".")) > 2:
|
||||
|
||||
|
|
@ -109,20 +123,46 @@ class CollectYetiRig(pyblish.api.InstancePlugin):
|
|||
if "<UDIM>" in texture:
|
||||
sequences = self.get_sequence(texture_filepath,
|
||||
pattern="<UDIM>")
|
||||
node_resources["files"].extend(sequences)
|
||||
item["files"].extend(sequences)
|
||||
|
||||
# Based textures (animated masks f.e)
|
||||
elif "%04d" in texture:
|
||||
sequences = self.get_sequence(texture_filepath,
|
||||
pattern="%04d")
|
||||
node_resources["files"].extend(sequences)
|
||||
item["files"].extend(sequences)
|
||||
# Assuming it is a fixed name
|
||||
else:
|
||||
node_resources["files"].append(texture_filepath)
|
||||
item["files"].append(texture_filepath)
|
||||
else:
|
||||
node_resources["files"].append(texture_filepath)
|
||||
item["files"].append(texture_filepath)
|
||||
|
||||
resources.append(node_resources)
|
||||
resources.append(item)
|
||||
|
||||
# Collect all referenced files
|
||||
for reference_node in reference_nodes:
|
||||
ref_file = cmds.pgYetiGraph(node,
|
||||
node=reference_node,
|
||||
param="reference_file",
|
||||
getParamValue=True)
|
||||
|
||||
if not os.path.isfile(ref_file):
|
||||
raise RuntimeError("Reference file must be a full file path!")
|
||||
|
||||
# Create resource dict
|
||||
item = {"files": [],
|
||||
"source": ref_file,
|
||||
"node": node,
|
||||
"graphnode": reference_node,
|
||||
"param": "reference_file"}
|
||||
|
||||
ref_file_name = os.path.basename(ref_file)
|
||||
if "%04d" in ref_file_name:
|
||||
ref_files = self.get_sequence(ref_file)
|
||||
item["files"].extend(ref_files)
|
||||
else:
|
||||
item["files"].append(ref_file)
|
||||
|
||||
resources.append(item)
|
||||
|
||||
return resources
|
||||
|
||||
|
|
@ -141,7 +181,6 @@ class CollectYetiRig(pyblish.api.InstancePlugin):
|
|||
list: file sequence.
|
||||
|
||||
"""
|
||||
|
||||
from avalon.vendor import clique
|
||||
|
||||
escaped = re.escape(filename)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue