clean up the code with better selection command & version bump

This commit is contained in:
Kayla Man 2024-06-24 20:57:37 +08:00
parent cd905b747a
commit fe2d42299b
7 changed files with 32 additions and 25 deletions

View file

@ -4312,6 +4312,7 @@ def get_sequence(filepath, pattern="%04d"):
if re.match(re_pattern, f)]
pattern = [clique.PATTERNS["frames"]]
collection, remainder = clique.assemble(files, patterns=pattern)
collection, remainder = clique.assemble(
files, patterns=pattern, minimum_items=1)
return collection

View file

@ -29,14 +29,16 @@ class OxCacheLoader(plugin.Loader):
and allow published looks to also work for Ornatrix rigs and its caches.
"""
# Ensure Ornatrix is loaded
if not cmds.pluginInfo("Ornatrix.mll", query=True, loaded=True):
cmds.loadPlugin("Ornatrix.mll", quiet=True)
product_type = context["product"]["productType"]
# Build namespace
folder_name = context["folder"]["name"]
if namespace is None:
namespace = self.create_namespace(folder_name)
# Ensure Ornatrix is loaded
cmds.loadPlugin("Ornatrix.mll", quiet=True)
path = self.filepath_from_context(context)
settings = self.read_settings(path)

View file

@ -1,7 +1,7 @@
from typing import List
import maya.cmds as cmds
from ayon_core.pipeline import registered_host
from ayon_core.pipeline import registered_host,CreatorError
from ayon_core.pipeline.create import CreateContext
from ayon_maya.api import lib, plugin
@ -81,14 +81,20 @@ class OxRigLoader(plugin.ReferenceLoader):
"""
# Check of the nodes connect to the ornatrix-related nodes
ox_nodes = [node for node in nodes if cmds.nodeType(nodes) in
{"HairFromGuidesNode", "GuidesFromMeshNode",
"MeshFromStrandsNode", "SurfaceCombNode"}]
assert not ox_nodes, "No Ornatrix nodes in rig, this is a bug."
ox_node_types = (
"HairFromGuidesNode", "GuidesFromMeshNode",
"MeshFromStrandsNode", "SurfaceCombNode"
)
# Check of the nodes connect to the ornatrix-related nodes
ox_nodes = cmds.ls(nodes, type=ox_node_types)
assert ox_nodes, "No Ornatrix nodes in rig, this is a bug."
ox_geo_nodes = cmds.ls(nodes, assemblies=True, long=True)
ox_input = next((node for node in nodes if
node.endswith("input_SET")), None)
if not ox_input:
raise CreatorError("No node found in input_SET")
self.log.info("Creating variant: {}".format(variant))
creator_identifier = "io.openpype.creators.maya.oxcache"

View file

@ -13,25 +13,24 @@ class CollectOxCache(plugin.MayaInstancePlugin):
def process(self, instance):
settings = {"nodes": []}
nodes = []
ox_shapes = cmds.ls(instance[:], shapes=True, long=True)
for ox_shape in ox_shapes:
ox_shape_id = lib.get_id(ox_shape)
if not ox_shape_id:
continue
# Get transform data
parent = cmds.listRelatives(ox_shape, parent=True)[0]
mesh_shape_data = {"name": parent, "cbId": lib.get_id(parent)}
ox_cache_nodes = cmds.listConnections(
ox_shape, destination=True, type="HairFromGuidesNode") or []
if not ox_cache_nodes:
continue
# transfer cache file
shape_data = {
"shape": mesh_shape_data,
nodes.append({
"name": ox_shapes,
"cbId": lib.get_id(ox_shape),
"cbId": ox_shape_id,
"ox_nodes": ox_cache_nodes,
"cache_file_attributes": ["{}.cacheFilePath".format(ox_node)
for ox_node in ox_cache_nodes]
}
if shape_data["cbId"]:
settings["nodes"].append(shape_data)
instance.data["cachesettings"] = settings
})
instance.data["cachesettings"] = {"nodes": nodes}

View file

@ -46,10 +46,10 @@ class CollectOxRig(plugin.MayaInstancePlugin):
if not node_shape:
return []
ox_nodes = [
ox_node for ox_node in cmds.listConnections(node_shape, destination=True)
if cmds.nodeType(ox_node) in ORNATRIX_NODES
] or []
ox_nodes = cmds.ls(
cmds.listConnections(node_shape, destination=True) or [],
type=ORNATRIX_NODES)
ox_file_nodes = cmds.listConnections(ox_nodes, destination=False, type="file") or []
if not ox_file_nodes:
return []
@ -66,8 +66,7 @@ class CollectOxRig(plugin.MayaInstancePlugin):
filepath = os.path.join(root, texture)
files = lib.search_textures(filepath)
if files:
# Break out on first match in search paths..
break
continue
if not files:
raise KnownPublishError(

View file

@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-
"""Package declaring AYON addon 'maya' version."""
__version__ = "0.2.4"
__version__ = "0.2.8"

View file

@ -1,6 +1,6 @@
name = "maya"
title = "Maya"
version = "0.2.4"
version = "0.2.8"
client_dir = "ayon_maya"
ayon_required_addons = {