-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #116 from ynput/enhancement/OP-7085_ValidateNoAnim…
…ation Max: Validate No Animation
- Loading branch information
Showing
3 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
client/ayon_core/hosts/max/plugins/publish/validate_no_animation.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# -*- coding: utf-8 -*- | ||
import pyblish.api | ||
from pymxs import runtime as rt | ||
from ayon_core.pipeline import ( | ||
PublishValidationError, | ||
OptionalPyblishPluginMixin | ||
) | ||
from ayon_core.hosts.max.api.action import SelectInvalidAction | ||
|
||
|
||
def get_invalid_keys(obj): | ||
"""function to check on whether there is keyframe in | ||
Args: | ||
obj (str): object needed to check if there is a keyframe | ||
Returns: | ||
bool: whether invalid object(s) exist | ||
""" | ||
for transform in ["Position", "Rotation", "Scale"]: | ||
num_of_key = rt.NumKeys(rt.getPropertyController( | ||
obj.controller, transform)) | ||
if num_of_key > 0: | ||
return True | ||
return False | ||
|
||
|
||
class ValidateNoAnimation(pyblish.api.InstancePlugin, | ||
OptionalPyblishPluginMixin): | ||
"""Validates No Animation | ||
Ensure no keyframes on nodes in the Instance | ||
""" | ||
|
||
order = pyblish.api.ValidatorOrder | ||
families = ["model"] | ||
hosts = ["max"] | ||
optional = True | ||
label = "Validate No Animation" | ||
actions = [SelectInvalidAction] | ||
|
||
def process(self, instance): | ||
if not self.is_active(instance.data): | ||
return | ||
invalid = self.get_invalid(instance) | ||
if invalid: | ||
raise PublishValidationError( | ||
"Keyframes found on:\n\n{0}".format(invalid) | ||
, | ||
title="Keyframes on model" | ||
) | ||
|
||
@staticmethod | ||
def get_invalid(instance): | ||
"""Get invalid object(s) which have keyframe(s) | ||
Args: | ||
instance (pyblish.api.instance): Instance | ||
Returns: | ||
list: list of invalid objects | ||
""" | ||
invalid = [invalid for invalid in instance.data["members"] | ||
if invalid.isAnimated or get_invalid_keys(invalid)] | ||
|
||
return invalid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.1.6" | ||
__version__ = "0.1.7" |