This repository has been archived by the owner on Sep 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 128
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 #3100 from BigRoy/fix3085
- Loading branch information
Showing
4 changed files
with
282 additions
and
3 deletions.
There are no files selected for viewing
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
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
51 changes: 51 additions & 0 deletions
51
openpype/hosts/maya/plugins/publish/validate_visible_only.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,51 @@ | ||
import pyblish.api | ||
|
||
import openpype.api | ||
from openpype.hosts.maya.api.lib import iter_visible_nodes_in_range | ||
import openpype.hosts.maya.api.action | ||
|
||
|
||
class ValidateAlembicVisibleOnly(pyblish.api.InstancePlugin): | ||
"""Validates at least a single node is visible in frame range. | ||
This validation only validates if the `visibleOnly` flag is enabled | ||
on the instance - otherwise the validation is skipped. | ||
""" | ||
order = openpype.api.ValidateContentsOrder + 0.05 | ||
label = "Alembic Visible Only" | ||
hosts = ["maya"] | ||
families = ["pointcache", "animation"] | ||
actions = [openpype.hosts.maya.api.action.SelectInvalidAction] | ||
|
||
def process(self, instance): | ||
|
||
if not instance.data.get("visibleOnly", False): | ||
self.log.debug("Visible only is disabled. Validation skipped..") | ||
return | ||
|
||
invalid = self.get_invalid(instance) | ||
if invalid: | ||
start, end = self.get_frame_range(instance) | ||
raise RuntimeError("No visible nodes found in " | ||
"frame range {}-{}.".format(start, end)) | ||
|
||
@classmethod | ||
def get_invalid(cls, instance): | ||
|
||
if instance.data["family"] == "animation": | ||
# Special behavior to use the nodes in out_SET | ||
nodes = instance.data["out_hierarchy"] | ||
else: | ||
nodes = instance[:] | ||
|
||
start, end = cls.get_frame_range(instance) | ||
if not any(iter_visible_nodes_in_range(nodes, start, end)): | ||
# Return the nodes we have considered so the user can identify | ||
# them with the select invalid action | ||
return nodes | ||
|
||
@staticmethod | ||
def get_frame_range(instance): | ||
data = instance.data | ||
return data["frameStartHandle"], data["frameEndHandle"] |