Solved Python - Gradient userdata - Set colour and alpha

Hi there,

I'm looking for a method to set both colour and alpha gradients for a single userdata.

0af4483c-b3c5-47c9-ae58-0b2fbfb5598c-image.png

The attributes of the gradient I need to set are:

c4d.GRADIENTKNOT_POSITION
c4d.GRADIENTKNOT_COLOR

and for the alpha gradient:

c4d.GRADIENTKNOT_POSITION
c4d.GRADIENTKNOT_BRIGHTNESS

I can get the alpha gradient with:

Gradient.GetAlphaGradient(self)

but I can see no way to set it.

Anybody know what I'm missing?

Thanks,

Adam

Hello @pixelsinprogress,

Thank you for reaching out to us. I must unfortunately tell you that it currently is technically not possible to set the alpha values of a c4d.Gradient instance in Python.

In C++ this works because there Gradient::GetAlphaGradient returns a pointer to the underlying alpha gradient. The Python layer unfortunately makes a copy of that layer, severing the connection between the alpha gradient and its associated color gradient (which is also why the Python docs warn about that). I also tried some other venues of poking around in the alpha data by using C4DAtom.SetParameter, but these unfortunately also do not work in Python.

I have created a ticket for this to be fixed at some point, as I would agree this is something the Python layer should be able to handle. But this is not a bug, as this was done somewhat intentionally. So, it might take a long time before we (most likely @m_adam) will find the time to do it.

Cheers,
Ferdinand

MAXON SDK Specialist
developers.maxon.net

Hello @pixelsinprogress,

Thank you for reaching out to us. I must unfortunately tell you that it currently is technically not possible to set the alpha values of a c4d.Gradient instance in Python.

In C++ this works because there Gradient::GetAlphaGradient returns a pointer to the underlying alpha gradient. The Python layer unfortunately makes a copy of that layer, severing the connection between the alpha gradient and its associated color gradient (which is also why the Python docs warn about that). I also tried some other venues of poking around in the alpha data by using C4DAtom.SetParameter, but these unfortunately also do not work in Python.

I have created a ticket for this to be fixed at some point, as I would agree this is something the Python layer should be able to handle. But this is not a bug, as this was done somewhat intentionally. So, it might take a long time before we (most likely @m_adam) will find the time to do it.

Cheers,
Ferdinand

MAXON SDK Specialist
developers.maxon.net