diff --git a/client/ayon_core/hosts/maya/api/plugin.py b/client/ayon_core/hosts/maya/api/plugin.py index 01ca4f7875..aba5fd8903 100644 --- a/client/ayon_core/hosts/maya/api/plugin.py +++ b/client/ayon_core/hosts/maya/api/plugin.py @@ -22,6 +22,7 @@ from ayon_core.pipeline import ( LegacyCreator, LoaderPlugin, get_representation_path, + get_current_project_name, ) from ayon_core.pipeline.load import LoadError from ayon_core.client import get_asset_by_name @@ -585,6 +586,39 @@ class RenderlayerCreator(NewCreator, MayaCreatorBase): project_name) +def get_load_color_for_family(family, settings=None): + """Get color for family from settings. + + Args: + family (str): Family name. + settings (Optional[dict]): Settings dictionary. + + Returns: + Union[tuple[float, float, float], None]: RGB color. + + """ + if settings is None: + settings = get_project_settings(get_current_project_name()) + + colors = settings["maya"]["load"]["colors"] + color = colors.get(family) + if not color: + return None + + if len(color) == 3: + red, green, blue = color + elif len(color) == 4: + red, green, blue, _ = color + else: + raise ValueError("Invalid color definition {}".format(str(color))) + + if type(red, int): + red = red / 255.0 + green = green / 255.0 + blue = blue / 255.0 + return red, green, blue + + class Loader(LoaderPlugin): hosts = ["maya"] diff --git a/client/ayon_core/hosts/maya/plugins/load/load_arnold_standin.py b/client/ayon_core/hosts/maya/plugins/load/load_arnold_standin.py index c690d1c205..d70a43a8c3 100644 --- a/client/ayon_core/hosts/maya/plugins/load/load_arnold_standin.py +++ b/client/ayon_core/hosts/maya/plugins/load/load_arnold_standin.py @@ -16,6 +16,7 @@ from ayon_core.hosts.maya.api.lib import ( convert_to_maya_fps ) from ayon_core.hosts.maya.api.pipeline import containerise +from ayon_core.hosts.maya.api.plugin import get_load_color_for_family def is_sequence(files): @@ -72,11 +73,12 @@ class ArnoldStandinLoader(load.LoaderPlugin): # Set color. settings = get_project_settings(context["project"]["name"]) - color = settings['maya']['load']['colors'].get('ass') + color = get_load_color_for_family("ass", settings) if color is not None: + red, green, blue = color cmds.setAttr(root + ".useOutlinerColor", True) cmds.setAttr( - root + ".outlinerColor", color[0], color[1], color[2] + root + ".outlinerColor", red, green, blue ) with maintained_selection(): diff --git a/client/ayon_core/hosts/maya/plugins/load/load_gpucache.py b/client/ayon_core/hosts/maya/plugins/load/load_gpucache.py index 00a76d374b..cdaaeeae6a 100644 --- a/client/ayon_core/hosts/maya/plugins/load/load_gpucache.py +++ b/client/ayon_core/hosts/maya/plugins/load/load_gpucache.py @@ -9,6 +9,7 @@ from ayon_core.pipeline import ( get_representation_path ) from ayon_core.settings import get_project_settings +from ayon_core.hosts.maya.api.plugin import get_load_color_for_family class GpuCacheLoader(load.LoaderPlugin): @@ -39,13 +40,12 @@ class GpuCacheLoader(load.LoaderPlugin): project_name = context["project"]["name"] settings = get_project_settings(project_name) - colors = settings['maya']['load']['colors'] - c = colors.get('model') - if c is not None: + color = get_load_color_for_family("model", settings) + if color is not None: + red, green, blue = color cmds.setAttr(root + ".useOutlinerColor", 1) cmds.setAttr( - root + ".outlinerColor", - (float(c[0]) / 255), (float(c[1]) / 255), (float(c[2]) / 255) + root + ".outlinerColor", red, green, blue ) # Create transform with shape diff --git a/client/ayon_core/hosts/maya/plugins/load/load_redshift_proxy.py b/client/ayon_core/hosts/maya/plugins/load/load_redshift_proxy.py index dd378602c9..8910d0fcd0 100644 --- a/client/ayon_core/hosts/maya/plugins/load/load_redshift_proxy.py +++ b/client/ayon_core/hosts/maya/plugins/load/load_redshift_proxy.py @@ -16,6 +16,7 @@ from ayon_core.hosts.maya.api.lib import ( unique_namespace ) from ayon_core.hosts.maya.api.pipeline import containerise +from ayon_core.hosts.maya.api.plugin import get_load_color_for_family class RedshiftProxyLoader(load.LoaderPlugin): @@ -59,12 +60,13 @@ class RedshiftProxyLoader(load.LoaderPlugin): # colour the group node project_name = context["project"]["name"] settings = get_project_settings(project_name) - colors = settings['maya']['load']['colors'] - c = colors.get(family) - if c is not None: + color = get_load_color_for_family(family, settings) + if color is not None: + red, green, blue = color cmds.setAttr("{0}.useOutlinerColor".format(group_node), 1) - cmds.setAttr("{0}.outlinerColor".format(group_node), - c[0], c[1], c[2]) + cmds.setAttr( + "{0}.outlinerColor".format(group_node), red, green, blue + ) return containerise( name=name, diff --git a/client/ayon_core/hosts/maya/plugins/load/load_reference.py b/client/ayon_core/hosts/maya/plugins/load/load_reference.py index 36bd2e5969..75f42a9fe6 100644 --- a/client/ayon_core/hosts/maya/plugins/load/load_reference.py +++ b/client/ayon_core/hosts/maya/plugins/load/load_reference.py @@ -1,4 +1,3 @@ -import os import difflib import contextlib @@ -6,7 +5,7 @@ from maya import cmds import qargparse from ayon_core.settings import get_project_settings -import ayon_core.hosts.maya.api.plugin +from ayon_core.hosts.maya.api import plugin from ayon_core.hosts.maya.api.lib import ( maintained_selection, get_container_members, @@ -87,7 +86,7 @@ def preserve_modelpanel_cameras(container, log=None): cmds.modelPanel(panel, edit=True, camera=new_camera) -class ReferenceLoader(ayon_core.hosts.maya.api.plugin.ReferenceLoader): +class ReferenceLoader(plugin.ReferenceLoader): """Reference file""" families = ["model", @@ -185,14 +184,16 @@ class ReferenceLoader(ayon_core.hosts.maya.api.plugin.ReferenceLoader): "{}.displayHandle".format(group_name), display_handle ) - colors = settings['maya']['load']['colors'] - c = colors.get(family) - if c is not None: + color = plugin.get_load_color_for_family(family, settings) + if color is not None: + red, green, blue = color cmds.setAttr("{}.useOutlinerColor".format(group_name), 1) - cmds.setAttr("{}.outlinerColor".format(group_name), - (float(c[0]) / 255), - (float(c[1]) / 255), - (float(c[2]) / 255)) + cmds.setAttr( + "{}.outlinerColor".format(group_name), + red, + green, + blue + ) cmds.setAttr( "{}.displayHandle".format(group_name), display_handle diff --git a/client/ayon_core/hosts/maya/plugins/load/load_vdb_to_arnold.py b/client/ayon_core/hosts/maya/plugins/load/load_vdb_to_arnold.py index 98f98330d7..c68fddc60a 100644 --- a/client/ayon_core/hosts/maya/plugins/load/load_vdb_to_arnold.py +++ b/client/ayon_core/hosts/maya/plugins/load/load_vdb_to_arnold.py @@ -5,6 +5,7 @@ from ayon_core.pipeline import ( load, get_representation_path ) +from ayon_core.hosts.maya.api.plugin import get_load_color_for_family # TODO aiVolume doesn't automatically set velocity fps correctly, set manual? @@ -50,16 +51,11 @@ class LoadVDBtoArnold(load.LoaderPlugin): project_name = context["project"]["name"] settings = get_project_settings(project_name) - colors = settings['maya']['load']['colors'] - - c = colors.get(family) - if c is not None: + color = get_load_color_for_family(family, settings) + if color is not None: + red, green, blue = color cmds.setAttr(root + ".useOutlinerColor", 1) - cmds.setAttr(root + ".outlinerColor", - (float(c[0]) / 255), - (float(c[1]) / 255), - (float(c[2]) / 255) - ) + cmds.setAttr(root + ".outlinerColor", red, green, blue) # Create VRayVolumeGrid grid_node = cmds.createNode("aiVolume", diff --git a/client/ayon_core/hosts/maya/plugins/load/load_vdb_to_redshift.py b/client/ayon_core/hosts/maya/plugins/load/load_vdb_to_redshift.py index 426e85cf7c..1bc75ae4c6 100644 --- a/client/ayon_core/hosts/maya/plugins/load/load_vdb_to_redshift.py +++ b/client/ayon_core/hosts/maya/plugins/load/load_vdb_to_redshift.py @@ -5,6 +5,7 @@ from ayon_core.pipeline import ( load, get_representation_path ) +from ayon_core.hosts.maya.api.plugin import get_load_color_for_family class LoadVDBtoRedShift(load.LoaderPlugin): @@ -69,16 +70,11 @@ class LoadVDBtoRedShift(load.LoaderPlugin): project_name = context["project"]["name"] settings = get_project_settings(project_name) - colors = settings['maya']['load']['colors'] - - c = colors.get(family) - if c is not None: + color = get_load_color_for_family(family, settings) + if color is not None: + red, green, blue = color cmds.setAttr(root + ".useOutlinerColor", 1) - cmds.setAttr(root + ".outlinerColor", - (float(c[0])/255), - (float(c[1])/255), - (float(c[2])/255) - ) + cmds.setAttr(root + ".outlinerColor", red, green, blue) # Create VR volume_node = cmds.createNode("RedshiftVolumeShape", diff --git a/client/ayon_core/hosts/maya/plugins/load/load_vdb_to_vray.py b/client/ayon_core/hosts/maya/plugins/load/load_vdb_to_vray.py index ca0519900b..0c87162629 100644 --- a/client/ayon_core/hosts/maya/plugins/load/load_vdb_to_vray.py +++ b/client/ayon_core/hosts/maya/plugins/load/load_vdb_to_vray.py @@ -5,6 +5,7 @@ from ayon_core.pipeline import ( load, get_representation_path ) +from ayon_core.hosts.maya.api.plugin import get_load_color_for_family from maya import cmds @@ -129,15 +130,11 @@ class LoadVDBtoVRay(load.LoaderPlugin): project_name = context["project"]["name"] settings = get_project_settings(project_name) - colors = settings['maya']['load']['colors'] - - c = colors.get(family) - if c is not None: + color = get_load_color_for_family(family, settings) + if color is not None: + red, green, blue = color cmds.setAttr(root + ".useOutlinerColor", 1) - cmds.setAttr(root + ".outlinerColor", - float(c[0]) / 255, - float(c[1]) / 255, - float(c[2]) / 255) + cmds.setAttr(root + ".outlinerColor", red, green, blue) # Create VRayVolumeGrid grid_node = cmds.createNode("VRayVolumeGrid", diff --git a/client/ayon_core/hosts/maya/plugins/load/load_vrayproxy.py b/client/ayon_core/hosts/maya/plugins/load/load_vrayproxy.py index 9b36303b64..50b63f4f11 100644 --- a/client/ayon_core/hosts/maya/plugins/load/load_vrayproxy.py +++ b/client/ayon_core/hosts/maya/plugins/load/load_vrayproxy.py @@ -22,6 +22,7 @@ from ayon_core.hosts.maya.api.lib import ( unique_namespace ) from ayon_core.hosts.maya.api.pipeline import containerise +from ayon_core.hosts.maya.api.plugin import get_load_color_for_family class VRayProxyLoader(load.LoaderPlugin): @@ -80,15 +81,12 @@ class VRayProxyLoader(load.LoaderPlugin): # colour the group node project_name = context["project"]["name"] settings = get_project_settings(project_name) - colors = settings['maya']['load']['colors'] - c = colors.get(family) - if c is not None: + color = get_load_color_for_family(family, settings) + if color is not None: + red, green, blue = color cmds.setAttr("{0}.useOutlinerColor".format(group_node), 1) cmds.setAttr( - "{0}.outlinerColor".format(group_node), - (float(c[0]) / 255), - (float(c[1]) / 255), - (float(c[2]) / 255) + "{0}.outlinerColor".format(group_node), red, green, blue ) return containerise( diff --git a/client/ayon_core/hosts/maya/plugins/load/load_vrayscene.py b/client/ayon_core/hosts/maya/plugins/load/load_vrayscene.py index 92d2b32549..7b4edb0567 100644 --- a/client/ayon_core/hosts/maya/plugins/load/load_vrayscene.py +++ b/client/ayon_core/hosts/maya/plugins/load/load_vrayscene.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -import os import maya.cmds as cmds # noqa from ayon_core.settings import get_project_settings from ayon_core.pipeline import ( @@ -12,6 +11,7 @@ from ayon_core.hosts.maya.api.lib import ( unique_namespace ) from ayon_core.hosts.maya.api.pipeline import containerise +from ayon_core.hosts.maya.api.plugin import get_load_color_for_family class VRaySceneLoader(load.LoaderPlugin): @@ -58,14 +58,12 @@ class VRaySceneLoader(load.LoaderPlugin): # colour the group node project_name = context["project"]["name"] settings = get_project_settings(project_name) - colors = settings['maya']['load']['colors'] - c = colors.get(family) - if c is not None: + color = get_load_color_for_family(family, settings) + if color is not None: + red, green, blue = color cmds.setAttr("{0}.useOutlinerColor".format(root_node), 1) - cmds.setAttr("{0}.outlinerColor".format(root_node), - (float(c[0])/255), - (float(c[1])/255), - (float(c[2])/255) + cmds.setAttr( + "{0}.outlinerColor".format(root_node), red, green, blue ) return containerise( diff --git a/client/ayon_core/hosts/maya/plugins/load/load_yeti_cache.py b/client/ayon_core/hosts/maya/plugins/load/load_yeti_cache.py index d2fc1c0ab0..afbb632d87 100644 --- a/client/ayon_core/hosts/maya/plugins/load/load_yeti_cache.py +++ b/client/ayon_core/hosts/maya/plugins/load/load_yeti_cache.py @@ -13,6 +13,7 @@ from ayon_core.pipeline import ( ) from ayon_core.hosts.maya.api import lib from ayon_core.hosts.maya.api.pipeline import containerise +from ayon_core.hosts.maya.api.plugin import get_load_color_for_family # Do not reset these values on update but only apply on first load @@ -81,16 +82,11 @@ class YetiCacheLoader(load.LoaderPlugin): project_name = context["project"]["name"] settings = get_project_settings(project_name) - colors = settings['maya']['load']['colors'] - - c = colors.get(family) - if c is not None: + color = get_load_color_for_family(family, settings) + if color is not None: + red, green, blue = color cmds.setAttr(group_node + ".useOutlinerColor", 1) - cmds.setAttr(group_node + ".outlinerColor", - (float(c[0])/255), - (float(c[1])/255), - (float(c[2])/255) - ) + cmds.setAttr(group_node + ".outlinerColor", red, green, blue) nodes.append(group_node) diff --git a/client/ayon_core/hosts/maya/plugins/load/load_yeti_rig.py b/client/ayon_core/hosts/maya/plugins/load/load_yeti_rig.py index 2572e550e2..e7178be38b 100644 --- a/client/ayon_core/hosts/maya/plugins/load/load_yeti_rig.py +++ b/client/ayon_core/hosts/maya/plugins/load/load_yeti_rig.py @@ -1,11 +1,10 @@ import maya.cmds as cmds -from ayon_core.settings import get_current_project_settings -import ayon_core.hosts.maya.api.plugin +from ayon_core.hosts.maya.api import plugin from ayon_core.hosts.maya.api import lib -class YetiRigLoader(ayon_core.hosts.maya.api.plugin.ReferenceLoader): +class YetiRigLoader(plugin.ReferenceLoader): """This loader will load Yeti rig.""" families = ["yetiRig"] @@ -41,14 +40,12 @@ class YetiRigLoader(ayon_core.hosts.maya.api.plugin.ReferenceLoader): groupName=group_name ) - settings = get_current_project_settings() - colors = settings["maya"]["load"]["colors"] - c = colors.get("yetiRig") - if c is not None: + color = plugin.get_load_color_for_family("yetiRig") + if color is not None: + red, green, blue = color cmds.setAttr(group_name + ".useOutlinerColor", 1) cmds.setAttr( - group_name + ".outlinerColor", - (float(c[0]) / 255), (float(c[1]) / 255), (float(c[2]) / 255) + group_name + ".outlinerColor", red, green, blue ) self[:] = nodes diff --git a/client/ayon_core/settings/ayon_settings.py b/client/ayon_core/settings/ayon_settings.py index 1a353a5a64..5734ac0707 100644 --- a/client/ayon_core/settings/ayon_settings.py +++ b/client/ayon_core/settings/ayon_settings.py @@ -344,13 +344,6 @@ def _convert_maya_project_settings(ayon_settings, output): subitem["subset_name_filters"] = subitem.pop( "product_name_filters") - _convert_host_imageio(ayon_maya) - - ayon_maya_load = ayon_maya["load"] - load_colors = ayon_maya_load["colors"] - for key, color in tuple(load_colors.items()): - load_colors[key] = _convert_color(color) - output["maya"] = ayon_maya diff --git a/server_addon/maya/server/settings/loaders.py b/server_addon/maya/server/settings/loaders.py index 15d4275b80..df1172ae7d 100644 --- a/server_addon/maya/server/settings/loaders.py +++ b/server_addon/maya/server/settings/loaders.py @@ -1,40 +1,136 @@ from ayon_server.settings import BaseSettingsModel, SettingsField -from ayon_server.types import ColorRGBA_uint8 +from ayon_server.types import ColorRGB_float class ColorsSetting(BaseSettingsModel): - model: ColorRGBA_uint8 = SettingsField( - (209, 132, 30, 1.0), title="Model:") - rig: ColorRGBA_uint8 = SettingsField( - (59, 226, 235, 1.0), title="Rig:") - pointcache: ColorRGBA_uint8 = SettingsField( - (94, 209, 30, 1.0), title="Pointcache:") - animation: ColorRGBA_uint8 = SettingsField( - (94, 209, 30, 1.0), title="Animation:") - ass: ColorRGBA_uint8 = SettingsField( - (249, 135, 53, 1.0), title="Arnold StandIn:") - camera: ColorRGBA_uint8 = SettingsField( - (136, 114, 244, 1.0), title="Camera:") - fbx: ColorRGBA_uint8 = SettingsField( - (215, 166, 255, 1.0), title="FBX:") - mayaAscii: ColorRGBA_uint8 = SettingsField( - (67, 174, 255, 1.0), title="Maya Ascii:") - mayaScene: ColorRGBA_uint8 = SettingsField( - (67, 174, 255, 1.0), title="Maya Scene:") - setdress: ColorRGBA_uint8 = SettingsField( - (255, 250, 90, 1.0), title="Set Dress:") - layout: ColorRGBA_uint8 = SettingsField(( - 255, 250, 90, 1.0), title="Layout:") - vdbcache: ColorRGBA_uint8 = SettingsField( - (249, 54, 0, 1.0), title="VDB Cache:") - vrayproxy: ColorRGBA_uint8 = SettingsField( - (255, 150, 12, 1.0), title="VRay Proxy:") - vrayscene_layer: ColorRGBA_uint8 = SettingsField( - (255, 150, 12, 1.0), title="VRay Scene:") - yeticache: ColorRGBA_uint8 = SettingsField( - (99, 206, 220, 1.0), title="Yeti Cache:") - yetiRig: ColorRGBA_uint8 = SettingsField( - (0, 205, 125, 1.0), title="Yeti Rig:") + model: ColorRGB_float = SettingsField( + ( + 0.8196078431372549, + 0.5176470588235295, + 0.11764705882352941 + ), + title="Model:" + ) + rig: ColorRGB_float = SettingsField( + ( + 0.23137254901960785, + 0.8862745098039215, + 0.9215686274509803 + ), + title="Rig:" + ) + pointcache: ColorRGB_float = SettingsField( + ( + 0.3686274509803922, + 0.8196078431372549, + 0.11764705882352941 + ), + title="Pointcache:" + ) + animation: ColorRGB_float = SettingsField( + ( + 0.3686274509803922, + 0.8196078431372549, + 0.11764705882352941 + ), + title="Animation:" + ) + ass: ColorRGB_float = SettingsField( + ( + 0.9764705882352941, + 0.5294117647058824, + 0.20784313725490197 + ), + title="Arnold StandIn:" + ) + camera: ColorRGB_float = SettingsField( + ( + 0.5333333333333333, + 0.4470588235294118, + 0.9568627450980393 + ), + title="Camera:" + ) + fbx: ColorRGB_float = SettingsField( + ( + 0.8431372549019608, + 0.6509803921568628, + 1.0 + ), + title="FBX:" + ) + mayaAscii: ColorRGB_float = SettingsField( + ( + 0.2627450980392157, + 0.6823529411764706, + 1.0 + ), + title="Maya Ascii:" + ) + mayaScene: ColorRGB_float = SettingsField( + ( + 0.2627450980392157, + 0.6823529411764706, + 1.0 + ), + title="Maya Scene:" + ) + setdress: ColorRGB_float = SettingsField( + ( + 1.0, + 0.9803921568627451, + 0.35294117647058826 + ), + title="Set Dress:" + ) + layout: ColorRGB_float = SettingsField( + ( + 1.0, + 0.9803921568627451, + 0.35294117647058826 + ), + title="Layout:" + ) + vdbcache: ColorRGB_float = SettingsField( + ( + 0.9764705882352941, + 0.21176470588235294, + 0.0 + ), + title="VDB Cache:" + ) + vrayproxy: ColorRGB_float = SettingsField( + ( + 1.0, + 0.5882352941176471, + 0.047058823529411764 + ), + title="VRay Proxy:" + ) + vrayscene_layer: ColorRGB_float = SettingsField( + ( + 1.0, + 0.5882352941176471, + 0.047058823529411764 + ), + title="VRay Scene:" + ) + yeticache: ColorRGB_float = SettingsField( + ( + 0.38823529411764707, + 0.807843137254902, + 0.8627450980392157 + ), + title="Yeti Cache:" + ) + yetiRig: ColorRGB_float = SettingsField( + ( + 0.0, + 0.803921568627451, + 0.49019607843137253 + ), + title="Yeti Rig:" + ) class ReferenceLoaderModel(BaseSettingsModel): @@ -68,52 +164,84 @@ class LoadersModel(BaseSettingsModel): DEFAULT_LOADERS_SETTING = { "colors": { "model": [ - 209, 132, 30, 1.0 + 0.8196078431372549, + 0.5176470588235295, + 0.11764705882352941 ], "rig": [ - 59, 226, 235, 1.0 + 0.23137254901960785, + 0.8862745098039215, + 0.9215686274509803 ], "pointcache": [ - 94, 209, 30, 1.0 + 0.3686274509803922, + 0.8196078431372549, + 0.11764705882352941 ], "animation": [ - 94, 209, 30, 1.0 + 0.3686274509803922, + 0.8196078431372549, + 0.11764705882352941 ], "ass": [ - 249, 135, 53, 1.0 + 0.9764705882352941, + 0.5294117647058824, + 0.20784313725490197 ], "camera": [ - 136, 114, 244, 1.0 + 0.5333333333333333, + 0.4470588235294118, + 0.9568627450980393 ], "fbx": [ - 215, 166, 255, 1.0 + 0.8431372549019608, + 0.6509803921568628, + 1.0 ], "mayaAscii": [ - 67, 174, 255, 1.0 + 0.2627450980392157, + 0.6823529411764706, + 1.0 ], "mayaScene": [ - 67, 174, 255, 1.0 + 0.2627450980392157, + 0.6823529411764706, + 1.0 ], "setdress": [ - 255, 250, 90, 1.0 + 1.0, + 0.9803921568627451, + 0.35294117647058826 ], "layout": [ - 255, 250, 90, 1.0 + 1.0, + 0.9803921568627451, + 0.35294117647058826 ], "vdbcache": [ - 249, 54, 0, 1.0 + 0.9764705882352941, + 0.21176470588235294, + 0.0 ], "vrayproxy": [ - 255, 150, 12, 1.0 + 1.0, + 0.5882352941176471, + 0.047058823529411764 ], "vrayscene_layer": [ - 255, 150, 12, 1.0 + 1.0, + 0.5882352941176471, + 0.047058823529411764 ], "yeticache": [ - 99, 206, 220, 1.0 + 0.38823529411764707, + 0.807843137254902, + 0.8627450980392157 ], "yetiRig": [ - 0, 205, 125, 1.0 + 0.0, + 0.803921568627451, + 0.49019607843137253 ] }, "reference_loader": {