Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Python - Gradient userdata - Set colour and alpha

    Bugs
    python s26
    2
    2
    556
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • PixelsInProgressP
      PixelsInProgress
      last edited by m_adam

      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

      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand @PixelsInProgress
        last edited by

        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

        1 Reply Last reply Reply Quote 0
        • maxonM maxon moved this topic from Cinema 4D SDK on
        • First post
          Last post