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
    • Register
    • Register
    • Login

    How it works new CalcGradientPixel?

    Cinema 4D SDK
    python 2024
    3
    3
    672
    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.
    • mikeudinM
      mikeudin
      last edited by

      Hello guys!
      Here is my old versions Python Node code that was working perfectly before v2024:

      import c4d
      
      def main():
          global Color,Alpha,AlphaGradient
      
          Color = Alpha = c4d.Vector()
          AlphaGradient = Gradient.GetAlphaGradient()
      
          irs = c4d.modules.render.InitRenderStruct()
      
          if Gradient.InitRender(irs):
              Color = Gradient.CalcGradientPixel(Position)
              Gradient.FreeRender()
      
          if AlphaGradient and AlphaGradient.InitRender(irs):
              Alpha = AlphaGradient.CalcGradientPixel(Position)
              AlphaGradient.FreeRender()
      

      Now following a new API changes this code:

      import c4d
      
      def main():
          global Color,Alpha,AlphaGradient
      
          Color = Alpha = c4d.Vector()
          AlphaGradient = Gradient.GetAlphaGradient()
      
          irs = c4d.modules.render.InitRenderStruct()
      
          if Gradient:
              Color = Gradient.PrepareRenderData(irs).CalcGradientPixel(Position)
      
          if AlphaGradient:
              Alpha = AlphaGradient.PrepareRenderDataWithAlpha(irs).CalcGradientPixel(Position)
      
      Traceback (most recent call last):
        File "Gradient", line 14, in main
      Exception: no converter found for 'net.maxon.interface.gradientrenderdata-C'
      

      How it works a new Gradient now? 🤔

      Checkout my python tutorials, plugins, scripts, xpresso presets and more
      https://mikeudin.net

      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by

        Hi, @mikeudin, you need to import maxon

        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        1 Reply Last reply Reply Quote 0
        • lleallooL
          llealloo
          last edited by

          I am kind of surprised there isn't an easier way to sample a Gradient by a normalized 0-1 position 🤔

          Anyway, thanks @mikeudin for the snippet and @m_adam for the fix

          1 Reply Last reply Reply Quote 0
          • First post
            Last post