# Path: mayaLib/rigLib/utils/common.py
# def centerPivot(obj, targetPivot=None):
# def freezeTranform(obj):
# def deleteHistory(obj):
# def deleteNonDeformerHistory(obj):
# def deleteConnection(objAttrList):
# def setDrivenKey(driver, driverValueList, driven, drivenValueList, cvType='linear'):
# 
# Path: mayaLib/rigLib/utils/skin.py
# def selectSkinClusterObject():
# def disableInheritsTransformOnSkinClusters():
# def copySkinWeightBetweenMesh(selection=pm.ls(sl=True)):
# def copyBind(source, destination, sa='closestPoint', ia='closestJoint'):
# def copyBindSelected(selectionList):
# def findRelatedSkinCluster(geo):
# def saveSkinWeights(characterName, geoList,
#                     projectPath=str(pm.workspace(q=True, dir=True, rd=True) + 'scenes/') + 'rig/',
#                     skinWeightsDir='weights/skinCluster', swExt='.swt',
#                     doDirectory=True):
# def loadSkinWeights(characterName, geoList,
#                     projectPath=str(pm.workspace(q=True, dir=True, rd=True) + 'scenes/') + 'rig/',
#                     skinWeightsDir='weights/skinCluster', swExt='.swt'):
# def ngSkinToolInit(geo):
# def ngSkinToolRaplceLayer(geo, sourceLayer, destinationLayer):
# def ngSkinToolDeleteNode(geo):
# 
# Path: mayaLib/rigLib/utils/util.py
# def getDriverDrivenFromConstraint(constraint):
# def returnDriverObject(attribute, skipConversionNodes=False):
# def returnDrivenAttribute(attribute, skipConversionNodes=False):
# def returnDrivenObject(attribute, skipConversionNodes=True):
# def getAllObjectUnderGroup(group, type='mesh'):
# def moveShape(source, destination):
# def get_distance(obj1, obj2):
#     def ctr_dist(objA, objB):
# def get_distance_from_coords(bboxMin, bboxMax):
# def lock_and_hide_all(node):
# def unlock_and_unhide_all(node):
# def no_render(tgt):
# def invertSelection():
# def getPlanarRadiusBBOXFromTransform(transform, radiusFactor=2):
# def matrixConstrain(driver, driven, parent=None, translate=True, rotate=True, scale=False):


import pymel.core as pm
from mayaLib.rigLib.utils import common
from mayaLib.rigLib.utils import skin
from mayaLib.rigLib.utils import util
        self.shapeGrp = pm.group(n='oldShape_GRP', em=True)
        self.shapeGrp.visibility.set(0)

        # Get Shape and skin from Object
        skinCluster = skin.findRelatedSkinCluster(obj)
        if skinCluster:
            self.skin = skinCluster
        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

# Path: mayaLib/rigLib/utils/common.py
# def centerPivot(obj, targetPivot=None):
# def freezeTranform(obj):
# def deleteHistory(obj):
# def deleteNonDeformerHistory(obj):
# def deleteConnection(objAttrList):
# def setDrivenKey(driver, driverValueList, driven, drivenValueList, cvType='linear'):
# 
# Path: mayaLib/rigLib/utils/skin.py
# def selectSkinClusterObject():
# def disableInheritsTransformOnSkinClusters():
# def copySkinWeightBetweenMesh(selection=pm.ls(sl=True)):
# def copyBind(source, destination, sa='closestPoint', ia='closestJoint'):
# def copyBindSelected(selectionList):
# def findRelatedSkinCluster(geo):
# def saveSkinWeights(characterName, geoList,
#                     projectPath=str(pm.workspace(q=True, dir=True, rd=True) + 'scenes/') + 'rig/',
#                     skinWeightsDir='weights/skinCluster', swExt='.swt',
#                     doDirectory=True):
# def loadSkinWeights(characterName, geoList,
#                     projectPath=str(pm.workspace(q=True, dir=True, rd=True) + 'scenes/') + 'rig/',
#                     skinWeightsDir='weights/skinCluster', swExt='.swt'):
# def ngSkinToolInit(geo):
# def ngSkinToolRaplceLayer(geo, sourceLayer, destinationLayer):
# def ngSkinToolDeleteNode(geo):
# 
# Path: mayaLib/rigLib/utils/util.py
# def getDriverDrivenFromConstraint(constraint):
# def returnDriverObject(attribute, skipConversionNodes=False):
# def returnDrivenAttribute(attribute, skipConversionNodes=False):
# def returnDrivenObject(attribute, skipConversionNodes=True):
# def getAllObjectUnderGroup(group, type='mesh'):
# def moveShape(source, destination):
# def get_distance(obj1, obj2):
#     def ctr_dist(objA, objB):
# def get_distance_from_coords(bboxMin, bboxMax):
# def lock_and_hide_all(node):
# def unlock_and_unhide_all(node):
# def no_render(tgt):
# def invertSelection():
# def getPlanarRadiusBBOXFromTransform(transform, radiusFactor=2):
# def matrixConstrain(driver, driven, parent=None, translate=True, rotate=True, scale=False):


# Path: mayaLib/rigLib/utils/pxrControl.py
import pymel.core as pm
from mayaLib.rigLib.utils import common
from mayaLib.rigLib.utils import skin
from mayaLib.rigLib.utils import util

        self.shapeGrp = pm.group(n='oldShape_GRP', em=True)
        self.shapeGrp.visibility.set(0)

        # Get Shape and skin from Object
        skinCluster = skin.findRelatedSkinCluster(obj)
        if skinCluster:
            self.skin = skinCluster
        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)