mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
added plugins from 3de
This commit is contained in:
parent
1e523caa52
commit
06e55d533a
4 changed files with 227 additions and 1 deletions
|
|
@ -24,4 +24,4 @@ class CollectSceneVersion(pyblish.api.ContextPlugin):
|
||||||
rootVersion = pype.get_version_from_path(filename)
|
rootVersion = pype.get_version_from_path(filename)
|
||||||
context.data['version'] = rootVersion
|
context.data['version'] = rootVersion
|
||||||
|
|
||||||
self.log.info('Scene Version: %s' % context.data('version'))
|
self.log.info('Scene Version: %s' % context.data.get('version'))
|
||||||
|
|
|
||||||
50
pype/plugins/maya/publish/validate_assembly_name.py
Normal file
50
pype/plugins/maya/publish/validate_assembly_name.py
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
import pyblish.api
|
||||||
|
import maya.cmds as cmds
|
||||||
|
import pype.maya.action
|
||||||
|
|
||||||
|
|
||||||
|
class ValidateAssemblyName(pyblish.api.InstancePlugin):
|
||||||
|
""" Ensure Assembly name ends with `GRP`
|
||||||
|
|
||||||
|
Check if assembly name ends with `_GRP` string.
|
||||||
|
"""
|
||||||
|
|
||||||
|
label = "Validate Assembly Name"
|
||||||
|
order = pyblish.api.ValidatorOrder
|
||||||
|
families = ["assembly"]
|
||||||
|
actions = [pype.maya.action.SelectInvalidAction]
|
||||||
|
active = False
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_invalid(cls, instance):
|
||||||
|
cls.log.info("Checking name of {}".format(instance.name))
|
||||||
|
|
||||||
|
content_instance = instance.data.get("setMembers", None)
|
||||||
|
if not content_instance:
|
||||||
|
cls.log.error("Instance has no nodes!")
|
||||||
|
return True
|
||||||
|
|
||||||
|
# All children will be included in the extracted export so we also
|
||||||
|
# validate *all* descendents of the set members and we skip any
|
||||||
|
# intermediate shapes
|
||||||
|
descendants = cmds.listRelatives(content_instance,
|
||||||
|
allDescendents=True,
|
||||||
|
fullPath=True) or []
|
||||||
|
descendants = cmds.ls(descendants, noIntermediate=True, long=True)
|
||||||
|
content_instance = list(set(content_instance + descendants))
|
||||||
|
assemblies = cmds.ls(content_instance, assemblies=True, long=True)
|
||||||
|
|
||||||
|
invalid = []
|
||||||
|
for cr in assemblies:
|
||||||
|
if not cr.endswith('_GRP'):
|
||||||
|
cls.log.error("{} doesn't end with _GRP".format(cr))
|
||||||
|
invalid.append(cr)
|
||||||
|
|
||||||
|
return invalid
|
||||||
|
|
||||||
|
def process(self, instance):
|
||||||
|
|
||||||
|
invalid = self.get_invalid(instance)
|
||||||
|
if invalid:
|
||||||
|
raise RuntimeError("Found {} invalid named assembly "
|
||||||
|
"items".format(len(invalid)))
|
||||||
98
pype/plugins/maya/publish/validate_model_name.py
Normal file
98
pype/plugins/maya/publish/validate_model_name.py
Normal file
|
|
@ -0,0 +1,98 @@
|
||||||
|
from maya import cmds
|
||||||
|
import pyblish.api
|
||||||
|
import pype.api
|
||||||
|
import pype.maya.action
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
class ValidateModelName(pyblish.api.InstancePlugin):
|
||||||
|
"""Validate name of model
|
||||||
|
|
||||||
|
starts with (somename)_###_(materialID)_GEO
|
||||||
|
materialID must be present in list
|
||||||
|
padding number doesn't have limit
|
||||||
|
|
||||||
|
"""
|
||||||
|
optional = True
|
||||||
|
order = pype.api.ValidateContentsOrder
|
||||||
|
hosts = ["maya"]
|
||||||
|
families = ["model"]
|
||||||
|
label = "Model Name"
|
||||||
|
actions = [pype.maya.action.SelectInvalidAction]
|
||||||
|
# path to shader names definitions
|
||||||
|
# TODO: move it to preset file
|
||||||
|
material_file = None
|
||||||
|
active = False
|
||||||
|
regex = '(.*)_(\\d)*_(.*)_(GEO)'
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_invalid(cls, instance):
|
||||||
|
|
||||||
|
# find out if supplied transform is group or not
|
||||||
|
def is_group(groupName):
|
||||||
|
try:
|
||||||
|
children = cmds.listRelatives(groupName, children=True)
|
||||||
|
for child in children:
|
||||||
|
if not cmds.ls(child, transforms=True):
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
|
||||||
|
invalid = []
|
||||||
|
content_instance = instance.data.get("setMembers", None)
|
||||||
|
if not content_instance:
|
||||||
|
cls.log.error("Instance has no nodes!")
|
||||||
|
return True
|
||||||
|
pass
|
||||||
|
descendants = cmds.listRelatives(content_instance,
|
||||||
|
allDescendents=True,
|
||||||
|
fullPath=True) or []
|
||||||
|
|
||||||
|
descendants = cmds.ls(descendants, noIntermediate=True, long=True)
|
||||||
|
trns = cmds.ls(descendants, long=False, type=('transform'))
|
||||||
|
|
||||||
|
# filter out groups
|
||||||
|
filter = [node for node in trns if not is_group(node)]
|
||||||
|
|
||||||
|
# load shader list file as utf-8
|
||||||
|
if cls.material_file:
|
||||||
|
shader_file = open(cls.material_file, "r")
|
||||||
|
shaders = shader_file.readlines()
|
||||||
|
shader_file.close()
|
||||||
|
|
||||||
|
# strip line endings from list
|
||||||
|
shaders = map(lambda s: s.rstrip(), shaders)
|
||||||
|
|
||||||
|
# compile regex for testing names
|
||||||
|
r = re.compile(cls.regex)
|
||||||
|
|
||||||
|
for obj in filter:
|
||||||
|
m = r.match(obj)
|
||||||
|
if m is None:
|
||||||
|
cls.log.error("invalid name on: {}".format(obj))
|
||||||
|
invalid.append(obj)
|
||||||
|
else:
|
||||||
|
# if we have shader files and shader named group is in
|
||||||
|
# regex, test this group against names in shader file
|
||||||
|
if 'shader' in r.groupindex and shaders:
|
||||||
|
try:
|
||||||
|
if not m.group('shader') in shaders:
|
||||||
|
cls.log.error(
|
||||||
|
"invalid materialID on: {0} ({1})".format(
|
||||||
|
obj, m.group('shader')))
|
||||||
|
invalid.append(obj)
|
||||||
|
except IndexError:
|
||||||
|
# shader named group doesn't match
|
||||||
|
cls.log.error(
|
||||||
|
"shader group doesn't match: {}".format(obj))
|
||||||
|
invalid.append(obj)
|
||||||
|
|
||||||
|
return invalid
|
||||||
|
|
||||||
|
def process(self, instance):
|
||||||
|
|
||||||
|
invalid = self.get_invalid(instance)
|
||||||
|
|
||||||
|
if invalid:
|
||||||
|
raise RuntimeError("Model naming is invalid. See log.")
|
||||||
78
pype/plugins/maya/publish/validate_shader_name.py
Normal file
78
pype/plugins/maya/publish/validate_shader_name.py
Normal file
|
|
@ -0,0 +1,78 @@
|
||||||
|
from maya import cmds
|
||||||
|
|
||||||
|
import pyblish.api
|
||||||
|
import pype.api
|
||||||
|
import pype.maya.action
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
class ValidateShaderName(pyblish.api.InstancePlugin):
|
||||||
|
"""Validate shader name assigned.
|
||||||
|
|
||||||
|
It should be <assetName>_<*>_SHD
|
||||||
|
|
||||||
|
"""
|
||||||
|
optional = True
|
||||||
|
active = False
|
||||||
|
order = pype.api.ValidateContentsOrder
|
||||||
|
families = ["look"]
|
||||||
|
hosts = ['maya']
|
||||||
|
label = 'Validate Shaders Name'
|
||||||
|
actions = [pype.maya.action.SelectInvalidAction]
|
||||||
|
regex = r'(?P<asset>.*)_(.*)_SHD'
|
||||||
|
|
||||||
|
# The default connections to check
|
||||||
|
def process(self, instance):
|
||||||
|
|
||||||
|
invalid = self.get_invalid(instance)
|
||||||
|
if invalid:
|
||||||
|
raise RuntimeError("Found shapes with invalid shader names "
|
||||||
|
"assigned: "
|
||||||
|
"\n{}".format(invalid))
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_invalid(cls, instance):
|
||||||
|
|
||||||
|
invalid = []
|
||||||
|
|
||||||
|
# Get all shapes from the instance
|
||||||
|
content_instance = instance.data.get("setMembers", None)
|
||||||
|
if not content_instance:
|
||||||
|
cls.log.error("Instance has no nodes!")
|
||||||
|
return True
|
||||||
|
pass
|
||||||
|
descendants = cmds.listRelatives(content_instance,
|
||||||
|
allDescendents=True,
|
||||||
|
fullPath=True) or []
|
||||||
|
|
||||||
|
descendants = cmds.ls(descendants, noIntermediate=True, long=True)
|
||||||
|
shapes = cmds.ls(descendants, type=["nurbsSurface", "mesh"], long=True)
|
||||||
|
asset_name = instance.data.get("asset", None)
|
||||||
|
|
||||||
|
# Check the number of connected shadingEngines per shape
|
||||||
|
r = re.compile(cls.regex)
|
||||||
|
for shape in shapes:
|
||||||
|
shading_engines = cmds.listConnections(shape,
|
||||||
|
destination=True,
|
||||||
|
type="shadingEngine") or []
|
||||||
|
shaders = cmds.ls(
|
||||||
|
cmds.listConnections(shading_engines), materials=1
|
||||||
|
)
|
||||||
|
|
||||||
|
for shader in shaders:
|
||||||
|
m = r.match(cls.regex, shader)
|
||||||
|
if m is None:
|
||||||
|
invalid.append(shape)
|
||||||
|
cls.log.error(
|
||||||
|
"object {0} has invalid shader name {1}".format(shape,
|
||||||
|
shader)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
if 'asset' in r.groupindex:
|
||||||
|
if m.group('asset') != asset_name:
|
||||||
|
invalid.append(shape)
|
||||||
|
cls.log.error(("object {0} has invalid "
|
||||||
|
"shader name {1}").format(shape,
|
||||||
|
shader))
|
||||||
|
|
||||||
|
return invalid
|
||||||
Loading…
Add table
Add a link
Reference in a new issue