mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-26 13:52:15 +01:00
Validate shading engine naming.
Shading engines should be named after their surface shader to bring clarity to the look manager.
This commit is contained in:
parent
d61ba75375
commit
b70462b555
2 changed files with 61 additions and 1 deletions
|
|
@ -389,7 +389,9 @@ class CollectLook(pyblish.api.InstancePlugin):
|
|||
# Collect changes to "custom" attributes
|
||||
node_attrs = get_look_attrs(node)
|
||||
|
||||
self.log.info(node_attrs)
|
||||
self.log.info(
|
||||
"Node \"{0}\" attributes: {1}".format(node, node_attrs)
|
||||
)
|
||||
|
||||
# Only include if there are any properties we care about
|
||||
if not node_attrs:
|
||||
|
|
|
|||
58
pype/plugins/maya/publish/validate_look_shading_group.py
Normal file
58
pype/plugins/maya/publish/validate_look_shading_group.py
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
from maya import cmds
|
||||
|
||||
import pyblish.api
|
||||
import pype.api
|
||||
import pype.maya.action
|
||||
|
||||
|
||||
class ValidateShadingEngine(pyblish.api.InstancePlugin):
|
||||
"""Validate all shading engines are named after the surface material.
|
||||
|
||||
Shading engines should be named "{surface_shader}SG"
|
||||
"""
|
||||
|
||||
order = pype.api.ValidateContentsOrder
|
||||
families = ["look"]
|
||||
hosts = ["maya"]
|
||||
label = "Look Shading Engine Naming"
|
||||
actions = [
|
||||
pype.maya.action.SelectInvalidAction, pype.api.RepairAction
|
||||
]
|
||||
|
||||
# The default connections to check
|
||||
def process(self, instance):
|
||||
|
||||
invalid = self.get_invalid(instance)
|
||||
if invalid:
|
||||
raise RuntimeError(
|
||||
"Found shading engines with incorrect naming:"
|
||||
"\n{}".format(invalid)
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def get_invalid(cls, instance):
|
||||
shapes = cmds.ls(instance, type=["nurbsSurface", "mesh"], long=True)
|
||||
invalid = []
|
||||
for shape in shapes:
|
||||
shading_engines = cmds.listConnections(
|
||||
shape, destination=True, type="shadingEngine"
|
||||
) or []
|
||||
for shading_engine in shading_engines:
|
||||
name = (
|
||||
cmds.listConnections(shading_engine + ".surfaceShader")[0]
|
||||
+ "SG"
|
||||
)
|
||||
if shading_engine != name:
|
||||
invalid.append(shading_engine)
|
||||
|
||||
return list(set(invalid))
|
||||
|
||||
@classmethod
|
||||
def repair(cls, instance):
|
||||
shading_engines = cls.get_invalid(instance)
|
||||
for shading_engine in shading_engines:
|
||||
name = (
|
||||
cmds.listConnections(shading_engine + ".surfaceShader")[0]
|
||||
+ "SG"
|
||||
)
|
||||
cmds.rename(shading_engine, name)
|
||||
Loading…
Add table
Add a link
Reference in a new issue