I made this gradient rig for a work project that I’m currently working with. With this Xpresso rig you can blend between two different gradients. You have to use same count of knots with both gradients, otherwise rig won’t work. There is options to restrict mixing to work only with knot position or color. I also added spline user data to remap gradient.

import c4d
from c4d import utils as u

def main():
    global GradOut # Output gradient
    GradCnt = Grad1.GetKnotCount() # Get start grad knot count
    knotListA = [] # List for storing knots
    knotListB = [] # List for storing knots
    resultList = [] # List for final grad
    for i in range(GradCnt): # Iterate through knots
        knotListA.append(Grad1.GetKnot(i)) # Store knot data
        knotListB.append(Grad2.GetKnot(i)) # Store knot data
    for i in range(GradCnt): # Loop
        if MPos: # If 'Mix Position' is enabled
            mixPos = u.MixNum(knotListA[i]['pos'],knotListB[i]['pos'], Mix) # Mix positions
        else: # Otherwise
            mixPos = knotListA[i]['pos'] # Take position from start gradient
        if MColor: # If 'Mix Color' is enabled
            mixCol = u.MixVec(knotListA[i]['col'],knotListB[i]['col'], Mix) # Mix colors
        else: # Otherwise
            mixCol = knotListA[i]['col'] # Take color from start gradient
        mixBias = u.MixNum(knotListA[i]['bias'],knotListB[i]['bias'], Mix) # Mix knots bias
        mixBrightness = u.MixNum(knotListA[i]['brightness'],knotListB[i]['brightness'], Mix)
        mixPos = u.RangeMap(mixPos, 0, 1, 0, 1, True, Spline) # Remap position with spline
        resultList.append({ # Collect mixed gradient data
        'brightness': mixBrightness,
        'index': i+1,
        'bias': mixBias,
        'pos': mixPos,
        'col': mixCol
        })
    MixGrad = c4d.Gradient() # Initialize gradient
    for i in range(GradCnt): # Loop
        MixGrad.InsertKnot(resultList[i]['col'],
        resultList[i]['brightness'],
        resultList[i]['pos'],
        resultList[i]['bias'],
        resultList[i]['index'])
    GradOut = MixGrad # Output mixed gradient

mix_gradients.c4d

Asset, Cinema 4D, Python, Xpresso