Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2211 from Ellipsanime/maya-validate-unique-names
Browse files Browse the repository at this point in the history
  • Loading branch information
mkolar authored Nov 9, 2021
2 parents 8bb4e42 + 6052561 commit 0320330
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
39 changes: 39 additions & 0 deletions openpype/plugins/publish/validate_unique_names.py
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))
5 changes: 5 additions & 0 deletions openpype/settings/defaults/project_settings/maya.json
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,11 @@
"optional": true,
"active": true
},
"ValidateUniqueNames": {
"enabled": false,
"optional": true,
"active": true
},
"ValidateRigContents": {
"enabled": false,
"optional": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,10 @@
{
"key": "ValidateTransformZero",
"label": "ValidateTransformZero"
},
{
"key": "ValidateUniqueNames",
"label": "ValidateUniqueNames"
}
]
}
Expand Down

0 comments on commit 0320330

Please sign in to comment.