mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
improved validators, added support for colorbleed IDs
This commit is contained in:
parent
eb61b4b2f0
commit
24e11ac047
4 changed files with 40 additions and 15 deletions
|
|
@ -41,7 +41,7 @@ class ValidateLookMembersNodeIds(pyblish.api.InstancePlugin):
|
|||
# Ensure all nodes have a cbId
|
||||
invalid = list()
|
||||
for node in members:
|
||||
if not cmds.getAttr("{}.mbID".format(node)):
|
||||
if not cmds.getAttr("{}.cbId".format(node)):
|
||||
invalid.append(node)
|
||||
|
||||
return invalid
|
||||
|
|
|
|||
|
|
@ -23,9 +23,7 @@ class ValidateResources(pyblish.api.InstancePlugin):
|
|||
def process(self, instance):
|
||||
|
||||
for resource in instance.data.get('resources', []):
|
||||
|
||||
# Required data
|
||||
assert "source" in resource
|
||||
assert "destination" in resource
|
||||
assert "files" in resource
|
||||
assert "source" in resource, "No source found"
|
||||
assert "files" in resource, "No files from source"
|
||||
assert all(os.path.exists(f) for f in resource['files'])
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class ValidateRigContents(pyblish.api.InstancePlugin):
|
|||
output_content = cmds.sets("out_SET", query=True) or []
|
||||
assert output_content, "Must have members in rig out_SET"
|
||||
|
||||
controls_content = cmds.set("controls_SET", query=True) or []
|
||||
controls_content = cmds.sets("controls_SET", query=True) or []
|
||||
assert controls_content, "Must have members in rig controls_SET"
|
||||
|
||||
root_node = cmds.ls(set_members, assemblies=True)
|
||||
|
|
@ -56,15 +56,15 @@ class ValidateRigContents(pyblish.api.InstancePlugin):
|
|||
self.invalid_controls = self.validate_controls(controls_content,
|
||||
hierarchy)
|
||||
|
||||
if self.invalid_hierachy:
|
||||
if self.invalid_hierarchy:
|
||||
self.log.error("Found nodes which reside outside of root group "
|
||||
"while they are set up for publishing."
|
||||
"\n%s" % self.invalid_hierachy)
|
||||
"\n%s" % self.invalid_hierarchy)
|
||||
error = True
|
||||
|
||||
if self.not_transforms:
|
||||
if self.invalid_controls:
|
||||
self.log.error("Only transforms can be part of the controls_SET."
|
||||
"\n%s" % self.not_transforms)
|
||||
"\n%s" % self.invalid_controls)
|
||||
error = True
|
||||
|
||||
if self.invalid_geometry:
|
||||
|
|
@ -100,6 +100,7 @@ class ValidateRigContents(pyblish.api.InstancePlugin):
|
|||
"""
|
||||
errors = []
|
||||
for node in nodes:
|
||||
print node
|
||||
if node not in hierarchy:
|
||||
errors.append(node)
|
||||
return errors
|
||||
|
|
@ -128,10 +129,12 @@ class ValidateRigContents(pyblish.api.InstancePlugin):
|
|||
# The user can add the shape node to the out_set, this will result
|
||||
# in none when querying allDescendents
|
||||
all_shapes = set_members + shapes
|
||||
all_long_names = [cmds.ls(i, long=True)[0] for i in all_shapes]
|
||||
|
||||
# geometry
|
||||
invalid_shapes = self.validate_hierarchy(hierarchy, all_shapes)
|
||||
self.invalid_hierachy.extend(invalid_shapes)
|
||||
invalid_shapes = self.validate_hierarchy(hierarchy,
|
||||
all_long_names)
|
||||
self.invalid_hierarchy.extend(invalid_shapes)
|
||||
for shape in all_shapes:
|
||||
nodetype = cmds.nodeType(shape)
|
||||
if nodetype in self.ignore_nodes:
|
||||
|
|
@ -157,8 +160,10 @@ class ValidateRigContents(pyblish.api.InstancePlugin):
|
|||
"""
|
||||
|
||||
errors = []
|
||||
invalid_controllers = self.validate_hierarchy(hierarchy, set_members)
|
||||
self.invalid_hierachy.extend(invalid_controllers)
|
||||
all_long_names = [cmds.ls(i, long=True)[0] for i in set_members]
|
||||
invalid_controllers = self.validate_hierarchy(hierarchy,
|
||||
all_long_names)
|
||||
self.invalid_hierarchy.extend(invalid_controllers)
|
||||
for node in set_members:
|
||||
nodetype = cmds.nodeType(node)
|
||||
if nodetype in self.ignore_nodes:
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
import logging
|
||||
|
||||
from maya import cmds
|
||||
|
||||
import pyblish.api
|
||||
import colorbleed.api
|
||||
|
||||
log = logging.getLogger("Rig Controllers")
|
||||
|
||||
|
||||
class ValidateRigControllers(pyblish.api.InstancePlugin):
|
||||
"""Check if the controllers have the transformation attributes set to
|
||||
|
|
@ -12,6 +16,7 @@ class ValidateRigControllers(pyblish.api.InstancePlugin):
|
|||
label = "Rig Controllers"
|
||||
hosts = ["maya"]
|
||||
families = ["colorbleed.rig"]
|
||||
actions = [colorbleed.api.RepairAction]
|
||||
|
||||
def process(self, instance):
|
||||
|
||||
|
|
@ -21,7 +26,7 @@ class ValidateRigControllers(pyblish.api.InstancePlugin):
|
|||
is_offset = list()
|
||||
|
||||
controls = cmds.sets("controls_SET", query=True)
|
||||
assert controls, "Must have controls in rig control_SET"
|
||||
assert controls, "Must have controls in rig controls_SET"
|
||||
|
||||
for control in controls:
|
||||
valid_keyed = self.validate_keyed_state(control)
|
||||
|
|
@ -41,15 +46,18 @@ class ValidateRigControllers(pyblish.api.InstancePlugin):
|
|||
if is_keyed:
|
||||
self.log.error("No controls can be keyes. Failed :\n"
|
||||
"%s" % is_keyed)
|
||||
error = True
|
||||
|
||||
if is_offset:
|
||||
self.log.error("All controls default transformation values. "
|
||||
"Failed :\n%s" % is_offset)
|
||||
error = True
|
||||
|
||||
if not_locked:
|
||||
self.log.error("All controls must have visibility "
|
||||
"attribute locked. Failed :\n"
|
||||
"%s" % not_locked)
|
||||
error = True
|
||||
|
||||
if error:
|
||||
raise RuntimeError("Invalid rig controllers. See log for details.")
|
||||
|
|
@ -78,3 +86,17 @@ class ValidateRigControllers(pyblish.api.InstancePlugin):
|
|||
if animation_curves:
|
||||
return False
|
||||
return True
|
||||
|
||||
@classmethod
|
||||
def repair(cls, instance):
|
||||
|
||||
# lock all controllers in controls_SET
|
||||
controls = cmds.sets("controls_SET", query=True)
|
||||
for control in controls:
|
||||
attr = "{}.visibility".format(control)
|
||||
locked = cmds.getAttr(attr, lock=True)
|
||||
if not locked:
|
||||
print("Locking visibility for %s" % control)
|
||||
cmds.setAttr(attr, lock=True)
|
||||
|
||||
continue
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue