add the docstring and the outlinercolor

This commit is contained in:
Kayla Man 2024-06-19 20:14:15 +08:00
parent 0d02b9f956
commit faca062036
2 changed files with 37 additions and 0 deletions

View file

@ -1,9 +1,11 @@
import json
import os
from ayon_core.pipeline import get_representation_path
from ayon_core.settings import get_project_settings
from ayon_maya.api import lib
from ayon_maya.api.pipeline import containerise
from ayon_maya.api import plugin
from ayon_maya.api.plugin import get_load_color_for_product_type
from maya import cmds, mel
@ -27,6 +29,7 @@ class OxCacheLoader(plugin.Loader):
and allow published looks to also work for Ornatrix rigs and its caches.
"""
product_type = context["product"]["productType"]
# Build namespace
folder_name = context["folder"]["name"]
if namespace is None:
@ -43,6 +46,19 @@ class OxCacheLoader(plugin.Loader):
for setting in settings["nodes"]:
nodes.extend(self.create_node(namespace, path, setting))
group_name = "{}:{}".format(namespace, name)
group_node = cmds.group(nodes, name=group_name)
project_name = context["project"]["name"]
settings = get_project_settings(project_name)
color = get_load_color_for_product_type(product_type, settings)
if color is not None:
red, green, blue = color
cmds.setAttr(group_node + ".useOutlinerColor", 1)
cmds.setAttr(group_node + ".outlinerColor", red, green, blue)
nodes.append(group_node)
self[:] = nodes
return containerise(
@ -102,6 +118,17 @@ class OxCacheLoader(plugin.Loader):
return namespace
def create_node(self, namespace, filepath, node_settings):
"""Use the cachesettings to create a shape node which
connects to HairFromGuidesNode with abc file cache.
Args:
namespace (str): namespace
filepath (str): filepath
node_settings (dict): node settings
Returns:
_type_: _description_
"""
nodes = []
orig_guide_name = node_settings["name"]
orig_shape_name = node_settings["shape"]["name"]
@ -122,6 +149,13 @@ class OxCacheLoader(plugin.Loader):
return nodes
def read_setting(self, path):
"""Read the ornatrix-related parameters from the cachesettings.
Args:
path (str): filepath of cachesettings
Returns:
dict: setting attributes
"""
path_no_ext, _ = os.path.splitext(path)
settings_path = f"{path_no_ext}.cachesettings"
with open(settings_path, "r") as fp:

View file

@ -39,6 +39,8 @@ class ColorsSetting(BaseSettingsModel):
(99, 206, 220, 1.0), title="Yeti Cache:")
yetiRig: ColorRGBA_uint8 = SettingsField(
(0, 205, 125, 1.0), title="Yeti Rig:")
oxcache: ColorRGBA_uint8 = SettingsField(
(156, 234, 195, 1.0), title="Ornatrix Cache:")
oxrig: ColorRGBA_uint8 = SettingsField(
(206, 234, 195, 1.0), title="Ornatrix Rig:")
# model: ColorRGB_float = SettingsField(
@ -251,6 +253,7 @@ DEFAULT_LOADERS_SETTING = {
"vrayscene_layer": [255, 150, 12, 1.0],
"yeticache": [99, 206, 220, 1.0],
"yetiRig": [0, 205, 125, 1.0],
"oxcache": [156, 234, 195, 1.0],
"oxrig": [206, 234, 195, 1.0]
# "model": [0.82, 0.52, 0.12],
# "rig": [0.23, 0.89, 0.92],