mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Merge branch 'develop' into bugfix/ayon_shotgrid_username
This commit is contained in:
commit
0fd3b05a58
3 changed files with 86 additions and 23 deletions
|
|
@ -653,10 +653,6 @@ def on_task_changed():
|
|||
"Can't set project for new context because path does not exist: {}"
|
||||
).format(workdir))
|
||||
|
||||
with lib.suspended_refresh():
|
||||
lib.set_context_settings()
|
||||
lib.update_content_on_context_change()
|
||||
|
||||
global _about_to_save
|
||||
if not lib.IS_HEADLESS and _about_to_save:
|
||||
# Let's prompt the user to update the context settings or not
|
||||
|
|
|
|||
|
|
@ -1,14 +1,18 @@
|
|||
import inspect
|
||||
|
||||
import pyblish.api
|
||||
|
||||
from maya import cmds
|
||||
from ayon_core.pipeline.publish import (
|
||||
context_plugin_should_run,
|
||||
PublishValidationError,
|
||||
OptionalPyblishPluginMixin
|
||||
)
|
||||
|
||||
|
||||
class ValidateCurrentRenderLayerIsRenderable(pyblish.api.ContextPlugin,
|
||||
OptionalPyblishPluginMixin):
|
||||
"""Validate if current render layer has a renderable camera
|
||||
"""Validate if current render layer has a renderable camera.
|
||||
|
||||
There is a bug in Redshift which occurs when the current render layer
|
||||
at file open has no renderable camera. The error raised is as follows:
|
||||
|
|
@ -32,8 +36,39 @@ class ValidateCurrentRenderLayerIsRenderable(pyblish.api.ContextPlugin,
|
|||
if not context_plugin_should_run(self, context):
|
||||
return
|
||||
|
||||
layer = cmds.editRenderLayerGlobals(query=True, currentRenderLayer=True)
|
||||
# This validator only makes sense when publishing renderlayer instances
|
||||
# with Redshift. We skip validation if there isn't any.
|
||||
if not any(self.is_active_redshift_render_instance(instance)
|
||||
for instance in context):
|
||||
return
|
||||
|
||||
cameras = cmds.ls(type="camera", long=True)
|
||||
renderable = any(c for c in cameras if cmds.getAttr(c + ".renderable"))
|
||||
assert renderable, ("Current render layer '%s' has no renderable "
|
||||
"camera" % layer)
|
||||
if not renderable:
|
||||
layer = cmds.editRenderLayerGlobals(query=True,
|
||||
currentRenderLayer=True)
|
||||
raise PublishValidationError(
|
||||
"Current render layer '{}' has no renderable camera".format(
|
||||
layer
|
||||
),
|
||||
description=inspect.getdoc(self)
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def is_active_redshift_render_instance(instance) -> bool:
|
||||
"""Return whether instance is an active renderlayer instance set to
|
||||
render with Redshift renderer."""
|
||||
if not instance.data.get("active", True):
|
||||
return False
|
||||
|
||||
# Check this before families just because it's a faster check
|
||||
if not instance.data.get("renderer") == "redshift":
|
||||
return False
|
||||
|
||||
families = set()
|
||||
families.add(instance.data.get("family"))
|
||||
families.update(instance.data.get("families", []))
|
||||
if "renderlayer" not in families:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import inspect
|
||||
|
||||
from maya import cmds
|
||||
|
||||
import pyblish.api
|
||||
|
|
@ -14,8 +16,7 @@ class ValidateModelContent(pyblish.api.InstancePlugin,
|
|||
OptionalPyblishPluginMixin):
|
||||
"""Adheres to the content of 'model' product type
|
||||
|
||||
- Must have one top group. (configurable)
|
||||
- Must only contain: transforms, meshes and groups
|
||||
See `get_description` for more details.
|
||||
|
||||
"""
|
||||
|
||||
|
|
@ -28,13 +29,16 @@ class ValidateModelContent(pyblish.api.InstancePlugin,
|
|||
validate_top_group = True
|
||||
optional = False
|
||||
|
||||
allowed = ('mesh', 'transform', 'nurbsCurve', 'nurbsSurface', 'locator')
|
||||
|
||||
@classmethod
|
||||
def get_invalid(cls, instance):
|
||||
|
||||
content_instance = instance.data.get("setMembers", None)
|
||||
if not content_instance:
|
||||
cls.log.error("Instance has no nodes!")
|
||||
return [instance.data["name"]]
|
||||
cls.log.error("Model instance has no nodes. "
|
||||
"It is not allowed to be empty")
|
||||
return [instance.data["instance_node"]]
|
||||
|
||||
# All children will be included in the extracted export so we also
|
||||
# validate *all* descendents of the set members and we skip any
|
||||
|
|
@ -46,30 +50,42 @@ class ValidateModelContent(pyblish.api.InstancePlugin,
|
|||
content_instance = list(set(content_instance + descendants))
|
||||
|
||||
# Ensure only valid node types
|
||||
allowed = ('mesh', 'transform', 'nurbsCurve', 'nurbsSurface', 'locator')
|
||||
nodes = cmds.ls(content_instance, long=True)
|
||||
valid = cmds.ls(content_instance, long=True, type=allowed)
|
||||
valid = cmds.ls(content_instance, long=True, type=cls.allowed)
|
||||
invalid = set(nodes) - set(valid)
|
||||
|
||||
if invalid:
|
||||
cls.log.error("These nodes are not allowed: %s" % invalid)
|
||||
# List as bullet points
|
||||
invalid_bullets = "\n".join(f"- {node}" for node in invalid)
|
||||
|
||||
cls.log.error(
|
||||
"These nodes are not allowed:\n{}\n\n"
|
||||
"The valid node types are: {}".format(
|
||||
invalid_bullets, ", ".join(cls.allowed))
|
||||
)
|
||||
return list(invalid)
|
||||
|
||||
if not valid:
|
||||
cls.log.error("No valid nodes in the instance")
|
||||
return True
|
||||
cls.log.error(
|
||||
"No valid nodes in the model instance.\n"
|
||||
"The valid node types are: {}".format(", ".join(cls.allowed))
|
||||
)
|
||||
return [instance.data["instance_node"]]
|
||||
|
||||
# Ensure it has shapes
|
||||
shapes = cmds.ls(valid, long=True, shapes=True)
|
||||
if not shapes:
|
||||
cls.log.error("No shapes in the model instance")
|
||||
return True
|
||||
return [instance.data["instance_node"]]
|
||||
|
||||
# Top group
|
||||
top_parents = set([x.split("|")[1] for x in content_instance])
|
||||
# Ensure single top group
|
||||
top_parents = {x.split("|", 2)[1] for x in content_instance}
|
||||
if cls.validate_top_group and len(top_parents) != 1:
|
||||
cls.log.error("Must have exactly one top group")
|
||||
return top_parents
|
||||
cls.log.error(
|
||||
"A model instance must have exactly one top group. "
|
||||
"Found top groups: {}".format(", ".join(top_parents))
|
||||
)
|
||||
return list(top_parents)
|
||||
|
||||
def _is_visible(node):
|
||||
"""Return whether node is visible"""
|
||||
|
|
@ -101,5 +117,21 @@ class ValidateModelContent(pyblish.api.InstancePlugin,
|
|||
if invalid:
|
||||
raise PublishValidationError(
|
||||
title="Model content is invalid",
|
||||
message="See log for more details"
|
||||
message="Model content is invalid. See log for more details.",
|
||||
description=self.get_description()
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def get_description(cls):
|
||||
return inspect.cleandoc(f"""
|
||||
### Model content is invalid
|
||||
|
||||
Your model instance does not adhere to the rules of a
|
||||
model product type:
|
||||
|
||||
- Must have at least one visible shape in it, like a mesh.
|
||||
- Must have one root node. When exporting multiple meshes they
|
||||
must be inside a group.
|
||||
- May only contain the following node types:
|
||||
{", ".join(cls.allowed)}
|
||||
""")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue