# 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/Ziva/ziva_fiber_tools.py
# def getAllObjectUnderGroup(group, type='mesh'):
# def addZivaFiber(obj):
# def createLoACurve(obj):
# def rivetCurve(curve, skeleton):
# def addLoA(curve, obj):
# def createLineOfAction(obj, skeleton):
# 
# Path: mayaLib/rigLib/Ziva/ziva_attachments_tools.py
# def getAllObjectUnderGroup(group, type='mesh'):
# def zivaFixedAttachment(stiffness=8):
# def zivaSlidingAttachment(stiffness=8):
# def paintProximity(zAttachement, min=0.0001, max=1):
# def addAttachment(source, dest, value, fixed=True):
# 
# Path: mayaLib/rigLib/Ziva/ziva_tools.py
# def zPolyCombine(geos):
# def harmonic_warp(source, destination, transfer_geos, tet_size=1):
# def bone_warp(source, destination, transfer_geos, tet_size=1):
# def ziva_check_intersection(geo1, geo2):
# def zivaRenameAll():
# def zivaMirror(from_side='L_', to_side='R_', suffix='_GEO'):


from pathlib import Path
from mayaLib.rigLib.utils import util as util
from mayaLib.rigLib.Ziva import ziva_fiber_tools as fiber
from mayaLib.rigLib.Ziva import ziva_attachments_tools as attachment
from mayaLib.rigLib.Ziva import ziva_tools as tool
import pymel.core as pm
import maya.mel as mel
import zBuilder.utils as zutils

    def save_zBuilder(self, file_name=None):
        workspace_dir = Path(pm.workspace(q=True, dir=True, rd=True)) / 'scenes' / 'zBuilder'
        workspace_dir.mkdir(parents=True, exist_ok=True)

        if file_name:
            zutils.save_rig(file_name, solver_name=str(self.zSolver.name()))
        else:
            file_name = str(workspace_dir) + self.character_name + '_' + self.rig_type
            zutils.save_rig(file_name, solver_name=str(self.zSolver.name()))

    def load_zBuilder(self, file_name=None):
        workspace_dir = Path(pm.workspace(q=True, dir=True, rd=True)) / 'scenes' / 'zBuilder'
        workspace_dir.mkdir(parents=True, exist_ok=True)

        if file_name:
            zutils.load_rig(file_name, solver_name=str(self.zSolver.name()))
        else:
            file_name = str(workspace_dir) + self.character_name + '_' + self.rig_type
            zutils.load_rig(file_name, solver_name=str(self.zSolver.name()))

    def add_zivaCache(self, zSolver=None):
        if zSolver:
            pm.select(zSolver)
        else:
            pm.select(self.zSolver)

        mel.eval('ziva -acn;')

    def clean_up(self):

# 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/Ziva/ziva_fiber_tools.py
# def getAllObjectUnderGroup(group, type='mesh'):
# def addZivaFiber(obj):
# def createLoACurve(obj):
# def rivetCurve(curve, skeleton):
# def addLoA(curve, obj):
# def createLineOfAction(obj, skeleton):
# 
# Path: mayaLib/rigLib/Ziva/ziva_attachments_tools.py
# def getAllObjectUnderGroup(group, type='mesh'):
# def zivaFixedAttachment(stiffness=8):
# def zivaSlidingAttachment(stiffness=8):
# def paintProximity(zAttachement, min=0.0001, max=1):
# def addAttachment(source, dest, value, fixed=True):
# 
# Path: mayaLib/rigLib/Ziva/ziva_tools.py
# def zPolyCombine(geos):
# def harmonic_warp(source, destination, transfer_geos, tet_size=1):
# def bone_warp(source, destination, transfer_geos, tet_size=1):
# def ziva_check_intersection(geo1, geo2):
# def zivaRenameAll():
# def zivaMirror(from_side='L_', to_side='R_', suffix='_GEO'):


# Path: mayaLib/rigLib/Ziva/ziva_build.py
from pathlib import Path
from mayaLib.rigLib.utils import util as util
from mayaLib.rigLib.Ziva import ziva_fiber_tools as fiber
from mayaLib.rigLib.Ziva import ziva_attachments_tools as attachment
from mayaLib.rigLib.Ziva import ziva_tools as tool
import pymel.core as pm
import maya.mel as mel
import zBuilder.utils as zutils


    def save_zBuilder(self, file_name=None):
        workspace_dir = Path(pm.workspace(q=True, dir=True, rd=True)) / 'scenes' / 'zBuilder'
        workspace_dir.mkdir(parents=True, exist_ok=True)

        if file_name:
            zutils.save_rig(file_name, solver_name=str(self.zSolver.name()))
        else:
            file_name = str(workspace_dir) + self.character_name + '_' + self.rig_type
            zutils.save_rig(file_name, solver_name=str(self.zSolver.name()))

    def load_zBuilder(self, file_name=None):
        workspace_dir = Path(pm.workspace(q=True, dir=True, rd=True)) / 'scenes' / 'zBuilder'
        workspace_dir.mkdir(parents=True, exist_ok=True)

        if file_name:
            zutils.load_rig(file_name, solver_name=str(self.zSolver.name()))
        else:
            file_name = str(workspace_dir) + self.character_name + '_' + self.rig_type
            zutils.load_rig(file_name, solver_name=str(self.zSolver.name()))

    def add_zivaCache(self, zSolver=None):
        if zSolver:
            pm.select(zSolver)
        else:
            pm.select(self.zSolver)

        mel.eval('ziva -acn;')

    def clean_up(self):

        tool.zivaRenameAll()