Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maya: Validate Animation Out Set Related Node Ids improve report #266

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<error id="main">
<title>Shape IDs mismatch original shape</title>
<description>## Shapes mismatch IDs with original shape

Meshes are detected where the (deformed) mesh has a different `cbId` than
the same mesh in its deformation history.
Theses should normally be the same.

### How to repair?

By using the repair action the IDs from the shape in history will be
copied to the deformed shape. For **animation** instances using the
repair action usually is usually the correct fix.

</description>
<detail>
### How does this happen?

When a deformer is applied in the scene on a referenced mesh that had no
deformers then Maya will create a new shape node for the mesh that
does not have the original id. Then on scene save new ids get created for the
meshes lacking a `cbId` and thus the mesh then has a different `cbId` than
the mesh in the deformation history.

</detail>
</error>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from ayon_core.pipeline.publish import (
RepairAction,
ValidateContentsOrder,
PublishValidationError,
PublishXmlValidationError,
OptionalPyblishPluginMixin,
get_plugin_settings,
apply_plugin_settings_automatically
Expand Down Expand Up @@ -56,40 +56,39 @@ def process(self, instance):
# if a deformer has been created on the shape
invalid = self.get_invalid(instance)
if invalid:
# TODO: Message formatting can be improved
raise PublishValidationError("Nodes found with mismatching "
"IDs: {0}".format(invalid),
title="Invalid node ids")

# Use the short names
invalid = cmds.ls(invalid)
invalid.sort()

# Construct a human-readable list
invalid = "\n".join("- {}".format(node) for node in invalid)

raise PublishXmlValidationError(
plugin=self,
message=(
"Nodes have different IDs than their input "
"history: \n{0}".format(invalid)
)
)

@classmethod
def get_invalid(cls, instance):
"""Get all nodes which do not match the criteria"""

invalid = []
types_to_skip = ["locator"]
types = ["mesh", "nurbsCurve", "nurbsSurface"]

# get asset id
nodes = instance.data.get("out_hierarchy", instance[:])
for node in nodes:
for node in cmds.ls(nodes, type=types, long=True):

# We only check when the node is *not* referenced
if cmds.referenceQuery(node, isNodeReferenced=True):
continue

# Check if node is a shape as deformers only work on shapes
obj_type = cmds.objectType(node, isAType="shape")
if not obj_type:
continue

# Skip specific types
if cmds.objectType(node) in types_to_skip:
continue

# Get the current id of the node
node_id = lib.get_id(node)
if not node_id:
invalid.append(node)
continue

history_id = lib.get_id_from_sibling(node)
if history_id is not None and node_id != history_id:
Expand Down
Loading