[maya]AnimCurveへの掛け算、足し算

掛け算は scaleKey の valueScale を使う

from maya import cmds 
import pymel.core as pm 

# translate
obj="sphere1"
trans1=".tx"
                    pm.scaleKey([str(obj) + trans1],
                     valuePivot=0, timeScale=1, 
                     hierarchy='none', 
                     float=(min,max), 
                     floatPivot=0, valueScale=-1, 
                     timePivot=0, scaleSpecifiedKeys=1, 
                     shape=1, time=(min,max), 
                     floatScale=1, controlPoints=0)

#rotation
pm.scaleKey([str(obj) + rot2], 
                        valuePivot=0, 
                        timeScale=1, 
                        hierarchy='none', 
                        float=(min,max), 
                        floatPivot=0, valueScale=-1, 
                        timePivot=0, scaleSpecifiedKeys=1, 
                        shape=1, 
                        time=(min,max), 
                        floatScale=1, controlPoints=0)

足し算は pm.pasteKey の valueOffset を使う

#min max
    animCurve_Arr = cmds.ls( type="animCurve" );
    print("animCurve_Arr= "+str(animCurve_Arr))
    min=0
    max=0
    for animCurve in animCurve_Arr:
        newMin = cmds.findKeyframe(animCurve,which="first")
        newMax = cmds.findKeyframe(animCurve,which="last")
        #print("newMin= "+str(newMin))
        #print("newMax= "+str(newMax))
        if(newMin<min):    
            min=newMin
            
        if(newMax>max):
            max=newMax
                
    print("min= "+str(min))
    print("max= "+str(max))

#rotaion
pm.copyKey((obj + rot1), hierarchy='none', shape=1, float=(min,max), controlPoints=0, time=(min,max))
pm.cutKey((obj + rot1), f=(min,max), t=(min,max), cl=1)
pm.pasteKey((obj + rot1), floatOffset=0, option='replace', copies=1, valueOffset=180, connect=1, timeOffset=0)
         
               

以下は Maya2022 >Bonus Tools >Animation >Mirror Animation のmelを

をPythonに変換したもの

例 モーションのアニムカーブのミラーのサンプル


def bt_applyMirrorAnim(axis, method, xforms, ignore, custom):
    
    trans = ""
    rot1 = ""
    rot2 = ""
    connection = []
    lockCheck1 = []
    lockCheck2 = []
    attrListOrig = []
    attrListFinal = []
    objList=cmds.ls(allPaths=1,long=1, selection=1)
    print("objList= "+str(objList))
    attrCount=0
    if xforms[0]==1:
        #attrListOrig[attrCount]=".tx"
        attrListOrig.append(".tx")
        attrCount+=1
        #attrListOrig[attrCount]=".ty"
        attrListOrig.append(".ty")
        attrCount+=1
        #attrListOrig[attrCount]=".tz"
        attrListOrig.append(".tz")
        attrCount+=1
        
    if xforms[1]==1:
        #attrListOrig[attrCount]=".rx"
        attrListOrig.append(".rx")
        attrCount+=1
        #attrListOrig[attrCount]=".ry"
        attrListOrig.append(".ry")
        attrCount+=1
        #attrListOrig[attrCount]=".rz"
        attrListOrig.append(".rz")
        attrCount+=1
        
    if xforms[2]==1:
        #attrListOrig[attrCount]=".sx"
        attrListOrig.append(".sx")
        attrCount+=1
        #attrListOrig[attrCount]=".sy"
        attrListOrig.append(".sy")
        attrCount+=1
        #attrListOrig[attrCount]=".sz"
        attrListOrig.append(".sz")
        attrCount+=1
        
    if (custom == 1) and (len(objList) == 2):
        userAttrList=pm.listAttr(objList[0], userDefined=1)
        #Look for custom attrs on first object
        for uAttr in userAttrList:
            if pm.mel.attributeExists(uAttr, objList[1]):
                #attrListOrig[attrCount]=("." + str(uAttr))
                attrListOrig.append("." + str(uAttr))
                #Check for same attr on second
                attrCount+=1

            
        
    if axis == 1:
        trans=".tx"
        rot1=".ry"
        rot2=".rz"
        
    
    elif axis == 2:
        trans=".ty"
        rot1=".rx"
        rot2=".rz"
        
    
    elif axis == 3:
        trans=".tz"
        rot1=".rx"
        rot2=".ry"
        
    elif axis == 4:
        trans=".ty"
        rot1=".ry"
        rot2=".rz"

    elif axis == 5:
        trans1=".tx"
        trans2=".ty"
        trans3=".tz"
        rot3=".rz"

    elif axis == 6:
        trans=".tx"
        trans1=".tx"
        trans2=".ty"
        trans3=".tz"
        rot1=".rx"
        rot2=".ry"
        rot3=".rz"

    animCurve_Arr = cmds.ls( type="animCurve" );
    print("animCurve_Arr= "+str(animCurve_Arr))
    min=0
    max=0
    for animCurve in animCurve_Arr:
        newMin = cmds.findKeyframe(animCurve,which="first")
        newMax = cmds.findKeyframe(animCurve,which="last")
        #print("newMin= "+str(newMin))
        #print("newMax= "+str(newMax))
        if(newMin<min):    
            min=newMin
            
        if(newMax>max):
            max=newMax
                
    print("min= "+str(min))
    print("max= "+str(max))

    """
    if (custom == 1) and (method == 5):
        # 接続を解除
        for obj in objList:
            deleteConnection(obj+".tx")
            deleteConnection(obj+".ty")
            deleteConnection(obj+".tz")
            deleteConnection(obj+".rx")
            deleteConnection(obj+".ry")
            deleteConnection(obj+".rz")
    """       
    if method == 4:
        print("method= 4   minus Mode...")
        if len(objList) != 2:
            print("Not 2 selected")
        
        """
        elif axis == 4:
        trans=".ty"
        rot1=".ry"
        rot2=".rz"

        """
        for obj in objList:
            print("obj= "+str(obj))
            if xforms[0]:
                lockCheck1=pm.listAttr((str(obj) + trans), l=1)
                
                # invert appropriate attrs and/or curves for objects
                #Translate
                if len(lockCheck1) == 0:
                    print("trans= "+str(trans))
                    #print(u"Inverting static value and/or animation for " + str(obj) + trans + "")
                    AttValue=pm.getAttr(str(obj) + trans)
                    print("AttValue= "+str(AttValue))
                    pm.setAttr((str(obj) + trans), (AttValue * -1))
                    #pm.setAttr((str(obj) + trans), (AttValue ))
                    pm.scaleKey([str(obj) + trans],
                     valuePivot=0, timeScale=1, 
                     hierarchy='none', 
                     float=(min,max), 
                     floatPivot=0, valueScale=-1, 
                     timePivot=0, scaleSpecifiedKeys=1, 
                     shape=1, time=(min,max), 
                     floatScale=1, controlPoints=0)
                    
                  
            if xforms[1]:
                animCurve_rot1=cmds.listConnections((str(obj) + rot1), t="animCurve")
                print("animCurve_rot1="+str(animCurve_rot1))
                lockCheck1=pm.listAttr((str(obj) + rot1), l=1)
                #Rotate
                if len(lockCheck1) == 0:
                    print("rot1= "+str(rot1))
                    print(u"Inverting static values and/or animation for " + str(obj) + rot1 + "")
                    
                    #pm.setAttr((str(obj) + rot1), (pm.getAttr(str(obj) + rot1) ))
                    #cmds.keyframe((str(obj) + rot1),e=True, time=(), r=True, vc=180)
                    """
                    pm.scaleKey([str(obj) + rot1], 
                        valuePivot=0, 
                        timeScale=1, 
                        hierarchy='none', 
                        float=(min,max), 
                        floatPivot=0, valueScale=+180, 
                        timePivot=0, scaleSpecifiedKeys=1, 
                        shape=1, 
                        time=(min,max), 
                        floatScale=1, controlPoints=0)
                    """
                    
                connection=pm.listConnections((obj + rot1), s=True, d=False)
                if(len(connection)>0):
                    if pm.mel.isAnimCurve(connection[0]):
                        print("obj= "+obj + " rot1= "+rot1)
                        pm.copyKey((obj + rot1), 
                            hierarchy='none', shape=1, float=(min,max), controlPoints=0, time=(min,max))
                        pm.cutKey((obj + rot1), 
                            f=(min,max), t=(min,max), cl=1)
                        pm.pasteKey((obj + rot1), 
                            floatOffset=0, option='replace', copies=1, valueOffset=180, connect=1, timeOffset=0)
                        
                   
                    else:
                        val=pm.getAttr(obj + rot3)
                        pm.setAttr((obj + rot3),  val+180)
                    
                    
                    
                animCurve_rot2=cmds.listConnections((str(obj) + rot2), t="animCurve")
                print("animCurve_rot2="+str(animCurve_rot2))     
                lockCheck1=pm.listAttr((str(obj) + rot2), l=1)
                if len(lockCheck1) == 0:
                    print("rot2= "+str(rot2))
                    print(u"Inverting static values and/or animation for " + str(obj) + rot2 + "")
                    pm.setAttr((str(obj) + rot2), (pm.getAttr(str(obj) + rot2) * -1))
                    pm.scaleKey([str(obj) + rot2], 
                        valuePivot=0, 
                        timeScale=1, 
                        hierarchy='none', 
                        float=(min,max), 
                        floatPivot=0, valueScale=-1, 
                        timePivot=0, scaleSpecifiedKeys=1, 
                        shape=1, 
                        time=(min,max), 
                        floatScale=1, controlPoints=0)
                    
                    
    elif method == 2:
        print("method=2   minus Mode...")
        if len(objList) != 2:
            print("Not 2 selected ")
        

        for obj in objList:
            print("obj= "+str(obj))
            if xforms[0]:
                lockCheck1=pm.listAttr((str(obj) + trans), l=1)
                
                # invert appropriate attrs and/or curves for objects
                #Translate
                if len(lockCheck1) == 0:
                    print("trans")
                    #print(u"Inverting static value and/or animation for " + str(obj) + trans + "")
                    AttValue=pm.getAttr(str(obj) + trans)
                    print("AttValue= "+str(AttValue))
                    pm.setAttr((str(obj) + trans), (AttValue * -1))
                    pm.scaleKey([str(obj) + trans], 
                    valuePivot=0, timeScale=1, 
                    hierarchy='none', float=(min,max), 
                    floatPivot=0, valueScale=-1, timePivot=0, 
                    scaleSpecifiedKeys=1, shape=1, 
                    time=(min,max), floatScale=1, 
                    controlPoints=0)
                    
                  
            if xforms[1]:
                lockCheck1=pm.listAttr((str(obj) + rot1), l=1)
                #Rotate
                if len(lockCheck1) == 0:
                    print("rot1")
                    print(u"Inverting static values and/or animation for " + str(obj) + rot1 + "")
                    pm.setAttr((str(obj) + rot1), (pm.getAttr(str(obj) + rot1) * -1))
                    pm.scaleKey([str(obj) + rot1], 
                        valuePivot=0, 
                        timeScale=1, 
                        hierarchy='none', 
                        float=(min,max), 
                        floatPivot=0, valueScale=-1, 
                        timePivot=0, scaleSpecifiedKeys=1, 
                        shape=1, 
                        time=(min,max), 
                        floatScale=1, controlPoints=0)
                     
                lockCheck1=pm.listAttr((str(obj) + rot2), l=1)
                if len(lockCheck1) == 0:
                    print("rot2")
                    print(u"Inverting static values and/or animation for " + str(obj) + rot2 + "")
                    pm.setAttr((str(obj) + rot2), (pm.getAttr(str(obj) + rot2) * -1))
                    pm.scaleKey([str(obj) + rot2], 
                        valuePivot=0, 
                        timeScale=1, 
                        hierarchy='none', 
                        float=(min,max), 
                        floatPivot=0, valueScale=-1, 
                        timePivot=0, scaleSpecifiedKeys=1, 
                        shape=1, 
                        time=(min,max), 
                        floatScale=1, controlPoints=0)
                    
                
            

    elif (method == 1) and (len(objList) == 2):
        print("method 1  base  No minus Mode...")
        print("elif (method == 1) and (len(objList) == 2)")
        
        first=objList[0]
        second=objList[1]
        print("first= "+str(first))
        print("second= "+str(second))
        print(u"Mirroring static values and animation for " + trans + ", " + rot1 + " and " + rot2 + " animation for " + str(first) + " and " + str(second) + "")
        #Check attrs for editability
        count=0
        for attr in attrListOrig:
            lockCheck1=pm.listAttr((first + attr), 
                l=1)
            lockCheck2=pm.listAttr((second + attr), 
                l=1)
            if (len(lockCheck1) != 0) and (ignore == 1):
                print("Ignoring " + str(first) + str(attr) + " because it is locked.")
                continue
                
            
            elif (len(lockCheck1) != 0) and (ignore == 0):
                print("Aborting : " + str(first) + str(attr) + " is locked.  Either unlock attributes or turn on IgnoreLockedAttributs in mirror options")
                
            
            elif (len(lockCheck2) != 0) and (ignore == 1):
                print("Ignoring " + str(second) + str(attr) + " because it is locked.")
                continue
                
            
            elif (len(lockCheck2) != 0) and (ignore == 0):
                print("Aborting : " + str(second) + str(attr) + " is locked.  Either unlock attributes or turn on IgnoreLockedAttributs in mirror options")
                
            
            else:
                #attrListFinal[count]=str(attr)
                attrListFinal.append(str(attr))
                count+=1
                
           
        cmds.select(first, r=1)
        #pm.mel.duplicatePreset(1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1)
        cmds.duplicate(returnRootsOnly=1)
        dup=cmds.ls(sl=True)
        tmpObj=cmds.rename(dup[0], 'tmp_transfer_obj')
        for attr in attrListFinal:
            connection=pm.listConnections((first + attr), s=True, d=False)
            #print("connection= "+str(connection) )
            
            if(len(connection)>0):
                if pm.mel.isAnimCurve(connection[0]):
                    #animCurve_Arr = cmds.ls( type="animCurve" );
                    #print("connection[0]= "+str(connection[0]) )
                    #newMin = cmds.findKeyframe(connection[0],which="first")
                    #newMax = cmds.findKeyframe(connection[0],which="last")
                    print("first= "+first + " attr= "+attr)
                    pm.copyKey((first + attr), 
                        hierarchy='none', shape=1, float=(min,max), controlPoints=0, time=(min,max))
             
                        
                    pm.cutKey((tmpObj + attr),f=(min,max), t=(min,max), cl=1)
                    pm.pasteKey((tmpObj + attr),floatOffset=0, option='replace', copies=1, valueOffset=0, connect=1, timeOffset=0)
                      
                
                else:
                    val=pm.getAttr(first + attr)
                    pm.setAttr((tmpObj + attr),  val)
        
            
        for attr in attrListFinal:
            connection=pm.listConnections((second + attr), s=True, d=False)
            if(len(connection)>0):
                if pm.mel.isAnimCurve(connection[0]):
                    print("second= "+second + " attr= "+attr)
                    pm.copyKey((second + attr), 
                        hierarchy='none', shape=1, float=(min,max), controlPoints=0, time=(min,max))
                    pm.cutKey((first + attr), 
                        f=(min,max), t=(min,max), cl=1)
                    pm.pasteKey((first + attr), 
                        floatOffset=0, option='replace', copies=1, valueOffset=0, connect=1, timeOffset=0)
                    
               
                else:
                    val=pm.getAttr(second + attr)
                    pm.setAttr((first + attr),  val)
                
       
        for attr in attrListFinal:
            connection=pm.listConnections((tmpObj + attr), s=True, d=False)
            if(len(connection)>0):
                if pm.mel.isAnimCurve(connection[0]):
                    print("tmpObj= "+tmpObj + " attr= "+attr)
                    pm.copyKey((tmpObj + attr), 
                        hierarchy='none', shape=1, float=(min,max), controlPoints=0, time=(min,max))
                    pm.cutKey((second + attr), 
                        f=(min,max), t=(min,max), cl=1)
                    pm.pasteKey((second + attr), 
                        floatOffset=0, option='replace', copies=1, valueOffset=0, connect=1, timeOffset=0)
                    
                
                else:
                    val=pm.getAttr(tmpObj + attr)
                    pm.setAttr((second + attr),  val)
                
    
        if xforms[0]:
            lockCheck1=pm.listAttr((str(first) + trans), 
                l=1)
            #if translate is on
            if len(lockCheck1) == 0:
                print("first= "+first + " trans= "+trans)
                #pm.setAttr((str(first) + trans), (pm.getAttr(str(first) + trans) * -1))
                pm.setAttr((str(first) + trans), (pm.getAttr(str(first) + trans) ))
                pm.scaleKey([str(first) + trans], 
                    scaleSpecifiedKeys=1, valuePivot=0, valueScale=1)
                
            lockCheck1=pm.listAttr((str(second) + trans), 
                l=1)
            if len(lockCheck1) == 0:
                print("second= "+second + " trans= "+trans)
                #pm.setAttr((str(second) + trans), (pm.getAttr(str(second) + trans) * -1))
                pm.setAttr((str(second) + trans), (pm.getAttr(str(second) + trans) ))
                pm.scaleKey([str(second) + trans], 
                    scaleSpecifiedKeys=1, valuePivot=0, valueScale=1)
                
            
        if xforms[1]:
            lockCheck1=pm.listAttr((str(first) + rot1), 
                l=1)
            #if rotate is on
            if len(lockCheck1) == 0:
                print("first= "+first + " rot1= "+rot1)
                #pm.setAttr((str(first) + rot1), (pm.getAttr(str(first) + rot1) * -1))
                pm.setAttr((str(first) + rot1), (pm.getAttr(str(first) + rot1) ))
                pm.scaleKey([str(first) + rot1], 
                    scaleSpecifiedKeys=1, valuePivot=0, valueScale=1)
                
            lockCheck1=pm.listAttr((str(first) + rot2), 
                l=1)
            if len(lockCheck1) == 0:
                print("first= "+first + " rot2= "+rot2)
                #pm.setAttr((str(first) + rot2), (pm.getAttr(str(first) + rot2) * -1))
                pm.setAttr((str(first) + rot2), (pm.getAttr(str(first) + rot2) ))
                pm.scaleKey([str(first) + rot2], 
                    scaleSpecifiedKeys=1, valuePivot=0, valueScale=1)
                
            lockCheck1=pm.listAttr((str(second) + rot1), 
                l=1)
            if len(lockCheck1) == 0:
                print("second= "+second + " rot1= "+rot1)
                #pm.setAttr((str(second) + rot1), (pm.getAttr(str(second) + rot1) * -1))
                pm.setAttr((str(second) + rot1), (pm.getAttr(str(second) + rot1) ))
                pm.scaleKey([str(second) + rot1], 
                    scaleSpecifiedKeys=1, valuePivot=0, valueScale=1)
                
            lockCheck1=pm.listAttr((str(second) + rot2), 
                l=1)
            if len(lockCheck1) == 0:
                print("second= "+second + " rot2= "+rot2)
                #pm.setAttr((str(second) + rot2), (pm.getAttr(str(second) + rot2) * -1))
                pm.setAttr((str(second) + rot2), (pm.getAttr(str(second) + rot2) ))
                pm.scaleKey([str(second) + rot2], 
                    scaleSpecifiedKeys=1, valuePivot=0, valueScale=1)
                
            
        pm.delete(tmpObj)
        cmds.select(objList, r=1)
        # Reset frame to current time so that changes are visually updated
        t=cmds.currentTime(query=1)
        cmds.currentTime(t, e=1)

    elif (method == 3) and (len(objList) == 2):
        print("equip_LR_mode------------------------------------------------")
        print("elif (method == 3)")
        
        first=objList[0]
        second=objList[1]
        print("first= "+str(first))
        print("second= "+str(second))
        print(u"Mirroring static values and animation for " + trans + ", " + rot1 + " and " + rot2 + " animation for " + str(first) + " and " + str(second) + "")
        #Check attrs for editability
        count=0
        for attr in attrListOrig:
            print("first= "+str(first)+" attr1= " +str(attr))
            lockCheck1=pm.listAttr((first + attr), 
                l=1)
            lockCheck2=pm.listAttr((second + attr), 
                l=1)
            if (len(lockCheck1) != 0) and (ignore == 1):
                print("Ignoring " + str(first) + str(attr) + " because it is locked.")
                continue
                
            
            elif (len(lockCheck1) != 0) and (ignore == 0):
                print("Aborting : " + str(first) + str(attr) + " is locked.  Either unlock attributes or turn on IgnoreLockedAttributs in mirror options")
                
            
            elif (len(lockCheck2) != 0) and (ignore == 1):
                print("Ignoring " + str(second) + str(attr) + " because it is locked.")
                continue
                
            
            elif (len(lockCheck2) != 0) and (ignore == 0):
                print("Aborting : " + str(second) + str(attr) + " is locked.  Either unlock attributes or turn on IgnoreLockedAttributs in mirror options")
                
            
            else:
                #attrListFinal[count]=str(attr)
                attrListFinal.append(str(attr))
                count+=1
                
           
        cmds.select(first, r=1)
        #pm.mel.duplicatePreset(1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1)
        cmds.duplicate(returnRootsOnly=1)
        dup=cmds.ls(sl=True)
        tmpObj=cmds.rename(dup[0], 'tmp_transfer_obj')
        for attr in attrListFinal:
            connection=pm.listConnections((first + attr), s=True, d=False)
            #print("connection= "+str(connection) )
            
            if(len(connection)>0):
                if pm.mel.isAnimCurve(connection[0]):
                    #animCurve_Arr = cmds.ls( type="animCurve" );
                    #print("connection[0]= "+str(connection[0]) )
                    #newMin = cmds.findKeyframe(connection[0],which="first")
                    #newMax = cmds.findKeyframe(connection[0],which="last")
                    print("tmp_transfer_obj  pasteKey first= "+str(first)+" attr1= " +str(attr))
                    pm.copyKey((first + attr), 
                        hierarchy='none', shape=1, float=(min,max), controlPoints=0, time=(min,max))
             
                        
                    pm.cutKey((tmpObj + attr), 
                        f=(min,max), t=(min,max), cl=1)
                    pm.pasteKey((tmpObj + attr), 
                        floatOffset=0, option='replace', copies=1, valueOffset=0, connect=1, timeOffset=0)
                      
                
                else:
                    val=pm.getAttr(first + attr)
                    pm.setAttr((tmpObj + attr),  val)
        
            
        for attr in attrListFinal:
            connection=pm.listConnections((second + attr), s=True, d=False)
            if(len(connection)>0):
                if pm.mel.isAnimCurve(connection[0]):
                    print("tmp_transfer_obj  pasteKey attr2= " +str(attr))
                    pm.copyKey((second + attr), 
                        hierarchy='none', shape=1, float=(min,max), controlPoints=0, time=(min,max))
                    pm.cutKey((first + attr), 
                        f=(min,max), t=(min,max), cl=1)
                    pm.pasteKey((first + attr), 
                        floatOffset=0, option='replace', copies=1, valueOffset=0, connect=1, timeOffset=0)
                    
               
                else:
                    val=pm.getAttr(second + attr)
                    pm.setAttr((first + attr),  val)
                
       
        for attr in attrListFinal:
            connection=pm.listConnections((tmpObj + attr), s=True, d=False)
            if(len(connection)>0):
                if pm.mel.isAnimCurve(connection[0]):
                    print("tmp_transfer_obj  pasteKey attr3= " +str(attr))
                    pm.copyKey((tmpObj + attr), 
                        hierarchy='none', shape=1, float=(min,max), controlPoints=0, time=(min,max))
                    pm.cutKey((second + attr), 
                        f=(min,max), t=(min,max), cl=1)
                    pm.pasteKey((second + attr), 
                        floatOffset=0, option='replace', copies=1, valueOffset=0, connect=1, timeOffset=0)
                    
                
                else:
                    val=pm.getAttr(tmpObj + attr)
                    pm.setAttr((second + attr),  val)
                
    
        if xforms[0]:
            lockCheck1=pm.listAttr((str(first) + trans), l=1)
            #if translate is on
            if len(lockCheck1) == 0:
                print("else tx   first"+str(first)+" trans1= " +str(trans1))
                pm.setAttr((str(first) + trans1), (pm.getAttr(str(first) + trans1) * -1))
                pm.scaleKey([str(first) + trans1],scaleSpecifiedKeys=1, valuePivot=0, valueScale=-1)
                print("else ty   first"+str(first)+" trans2= " +str(trans2))
                pm.setAttr((str(first) + trans2), (pm.getAttr(str(first) + trans2) * -1))
                pm.scaleKey([str(first) + trans2],scaleSpecifiedKeys=1, valuePivot=0, valueScale=-1)
                print("else tz   first"+str(first)+" trans3= " +str(trans3))
                pm.setAttr((str(first) + trans3), (pm.getAttr(str(first) + trans3) * -1))
                pm.scaleKey([str(first) + trans3],scaleSpecifiedKeys=1, valuePivot=0, valueScale=-1)
                
                print("else tx   second"+str(second)+" trans1= " +str(trans1))
                pm.setAttr((str(second) + trans1), (pm.getAttr(str(second) + trans1) * -1))
                pm.scaleKey([str(second) + trans1],scaleSpecifiedKeys=1, valuePivot=0, valueScale=-1)
                print("else ty   second"+str(second)+" trans2= " +str(trans2))
                pm.setAttr((str(second) + trans2), (pm.getAttr(str(second) + trans2) * -1))
                pm.scaleKey([str(second) + trans2],scaleSpecifiedKeys=1, valuePivot=0, valueScale=-1)
                print("else tz   second"+str(second)+" trans3= " +str(trans3))
                pm.setAttr((str(second) + trans3), (pm.getAttr(str(second) + trans3) * -1))
                pm.scaleKey([str(second) + trans3],scaleSpecifiedKeys=1, valuePivot=0, valueScale=-1)
    
        """    
        if xforms[1]:
            lockCheck1=pm.listAttr((str(first) + rot3), 
            if len(lockCheck1) == 0:
                print("------")
                connection=pm.listConnections((obj + rot1), s=True, d=False)
                if(len(connection)>0):
                    if pm.mel.isAnimCurve(connection[0]):
                        print("obj= "+obj + " rot1= "+rot1)
                        pm.copyKey((obj + rot1), 
                            hierarchy='none', shape=1, float=(min,max), controlPoints=0, time=(min,max))
                        pm.cutKey((obj + rot1), 
                            f=(min,max), t=(min,max), cl=1)
                        pm.pasteKey((obj + rot1), 
                            floatOffset=0, option='replace', copies=1, valueOffset=180, connect=1, timeOffset=0)
                        
                   
                    else:
                        val=pm.getAttr(obj + rot3)
                        pm.setAttr((obj + rot3),  val+180)
                print("------")
        """
        pm.delete(tmpObj)
        cmds.select(objList, r=1)
        # Reset frame to current time so that changes are visually updated
        t=cmds.currentTime(query=1)
        cmds.currentTime(t, e=1)

        

        
    elif (method == 1) and (len(objList) != 2):
        print("Wrong number of objects.  Select 2 transfroms to mirror between")
        
#example
bt_applyMirrorAnim(2, 2, [1,1,0], 1, 1) 
bt_applyMirrorAnim(4, 4, [1,1,0], 1, 1)
bt_applyMirrorAnim(5, 3, [1,1,0], 1, 1)
bt_applyMirrorAnim(2, 2, [1,1,0], 1, 1) 

参考

Maya AnimCurve のデータを Pythonで取得するメモ

https://qiita.com/syoyo/items/376541f60e7cdb346399