<commit_before>__author__ = '<NAME>'

import pymel.core as pm
from mayaLib.rigLib.utils import util
from mayaLib.rigLib.utils import common

def invertSelection(shape, faces):
    pm.select(shape+'.f[*]')
    pm.select(faces, deselect=True)
    #mel.eval('InvertSelection;')
    return pm.ls(sl=True)

class PxrStyleCtrl():
    """
    Create Geometry control like PIXAR
    """

    def __init__(self, obj):
        # Create backup Group
        self.shapeGrp = pm.group(n='oldShape_GRP', em=True)
        self.shapeGrp.visibility.set(0)

        # Get Shape and skin from Object
        shape = pm.ls(obj)[0].getShape()
        skinCluster = pm.listConnections(shape + '.inMesh', destination=False)
        if len(skinCluster) > 0:
            self.skin = pm.PyNode(skinCluster[0])
        else:
            print 'Missing SkinCluster'

        # Get joint influence of the skin
        influnces = self.skin.getInfluence(q=True)  # influences is joint
        for joint in influnces:
            constraint = pm.listRelatives(joint, children=True, type='constraint')
            if constraint:
                ctrl, jnt = util.getDriverDrivenFromConstraint(constraint[0])
                # duplicate mesh for a control
                emptyTransform, ctrlShape = self.duplicateSourceMesh(obj=obj, ctrl=ctrl)

                # move new shape under control and delete empty transform
                self.moveShapeAndbackUp(source=ctrlShape, destination=ctrl)
                pm.delete(emptyTransform)

                # connect control shape to skinCluster
                self.connectSkinCluster(ctrlShape, ctrl)

                # delete faces in the new shape based on selected joint
                self.deleteVertex(joint=joint, newShape=ctrlShape)

                # delete non deformer history
                common.deleteNonDeformerHistory(ctrlShape)

                # prevent chidlren selection hilight
                shape = ctrl[0].getShape()
                ctrl[0].selectionChildHighlighting.set(0)
                shape.selectionChildHighlighting.set(0)

        print 'DONE!'

    def duplicateSourceMesh(self, obj, ctrl):
        """

        :param obj:
        :param ctrl:
        :return: Mesh Shape for the Control<commit_msg>small update pxrControl<commit_after>__author__ = '<NAME>'

import pymel.core as pm
from mayaLib.rigLib.utils import util
from mayaLib.rigLib.utils import common

def invertSelection(shape, faces):
    pm.select(shape+'.f[*]')
    pm.select(faces, deselect=True)
    #mel.eval('InvertSelection;')
    return pm.ls(sl=True)

class PxrStyleCtrl():
    """
    Create Geometry control like PIXAR
    """

    def __init__(self, obj, deleteOldShapeGrp=True):
        # Create backup Group
        self.shapeGrp = pm.group(n='oldShape_GRP', em=True)
        self.shapeGrp.visibility.set(0)

        # Get Shape and skin from Object
        shape = pm.ls(obj)[0].getShape()
        skinCluster = pm.listConnections(shape + '.inMesh', destination=False)
        if len(skinCluster) > 0:
            self.skin = pm.PyNode(skinCluster[0])
        else:
            print 'Missing SkinCluster'

        # Get joint influence of the skin
        influnces = self.skin.getInfluence(q=True)  # influences is joint
        for joint in influnces:
            constraint = pm.listRelatives(joint, children=True, type='constraint')
            if constraint:
                ctrl, jnt = util.getDriverDrivenFromConstraint(constraint[0])
                # duplicate mesh for a control
                emptyTransform, ctrlShape = self.duplicateSourceMesh(obj=obj, ctrl=ctrl)

                # move new shape under control and delete empty transform
                self.moveShapeAndbackUp(source=ctrlShape, destination=ctrl)
                pm.delete(emptyTransform)

                # connect control shape to skinCluster
                self.connectSkinCluster(ctrlShape, ctrl)

                # delete faces in the new shape based on selected joint
                self.deleteVertex(joint=joint, newShape=ctrlShape)

                # delete non deformer history
                common.deleteNonDeformerHistory(ctrlShape)

                # prevent chidlren selection hilight
                shape = ctrl[0].getShape()
                ctrl[0].selectionChildHighlighting.set(0)
                shape.selectionChildHighlighting.set(0)

        if deleteOldShapeGrp:
            pm.delete(self.shapeGrp)

        print 'DONE!'

    def duplicateSourceMesh(self, obj, ctrl):
        """

        :param obj:
        :param ctrl:
        :return: Mesh Shape for the Control
{'fraction_non_alphanumeric': 0.08919270833333333, 'fraction_numerical': 0.00390625, 'mean_word_length': 2.2366573033707864, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2344779', 'n_tokens_mistral': 1307, 'n_tokens_neox': 1228, 'n_words': 313}