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

Maya: Validate Shape Zero do not keep fixed geometry vertices selected/active after repair #2456

Merged
Merged
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
26 changes: 18 additions & 8 deletions openpype/hosts/maya/plugins/publish/validate_shape_zero.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
import pyblish.api
import openpype.api
import openpype.hosts.maya.api.action
from openpype.hosts.maya.api import lib

from avalon.maya import maintained_selection


class ValidateShapeZero(pyblish.api.Validator):
"""shape can't have any values
"""Shape components may not have any "tweak" values

To solve this issue, try freezing the shapes. So long
as the translation, rotation and scaling values are zero,
you're all good.
To solve this issue, try freezing the shapes.

"""

Expand Down Expand Up @@ -47,13 +48,22 @@ def get_invalid(instance):
@classmethod
def repair(cls, instance):
invalid_shapes = cls.get_invalid(instance)
for shape in invalid_shapes:
cmds.polyCollapseTweaks(shape)
if not invalid_shapes:
return

with maintained_selection():
with lib.tool("selectSuperContext"):
for shape in invalid_shapes:
cmds.polyCollapseTweaks(shape)
# cmds.polyCollapseTweaks keeps selecting the geometry
# after each command. When running on many meshes
# after one another this tends to get really heavy
cmds.select(clear=True)

def process(self, instance):
"""Process all the nodes in the instance "objectSet"""

invalid = self.get_invalid(instance)
if invalid:
raise ValueError("Nodes found with shape or vertices not freezed"
"values: {0}".format(invalid))
raise ValueError("Shapes found with non-zero component tweaks: "
"{0}".format(invalid))