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 129
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 #2211 from Ellipsanime/maya-validate-unique-names
- Loading branch information
Showing
3 changed files
with
48 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from maya import cmds | ||
|
||
import pyblish.api | ||
import openpype.api | ||
import openpype.hosts.maya.api.action | ||
|
||
|
||
class ValidateUniqueNames(pyblish.api.Validator): | ||
"""transform names should be unique | ||
ie: using cmds.ls(someNodeName) should always return shortname | ||
""" | ||
|
||
order = openpype.api.ValidateContentsOrder | ||
hosts = ["maya"] | ||
families = ["model"] | ||
label = "Unique transform name" | ||
actions = [openpype.hosts.maya.api.action.SelectInvalidAction] | ||
|
||
@staticmethod | ||
def get_invalid(instance): | ||
"""Returns the invalid transforms in the instance. | ||
Returns: | ||
list: Non unique name transforms | ||
""" | ||
|
||
return [tr for tr in cmds.ls(instance, type="transform") | ||
if '|' in tr] | ||
|
||
def process(self, instance): | ||
"""Process all the nodes in the instance "objectSet""" | ||
|
||
invalid = self.get_invalid(instance) | ||
if invalid: | ||
raise ValueError("Nodes found with none unique names. " | ||
"values: {0}".format(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