Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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
    • Recent
    • Tags
    • Users
    • Register
    • Login

    [Cinema 4D/Redshift] How to insert knots into a Redshift Ramp Node

    Scheduled Pinned Locked Moved Cinema 4D SDK
    python2026windows
    3 Posts 2 Posters 20 Views 1 Watching
    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.
    • pislicesP Offline
      pislices
      last edited by

      Hi,

      I would like to figure out how I can insert knots into a Redshift Ramp node in a Node Editor material using Python. The gradient field doesn't seem to be exposed like other gradients within Cinema 4D, and I have not had success finding examples of how to write to it with the updated Node materials.

      The example here (with the suggested fix applied) is pretty much exactly what I'm hoping to accomplish, but it only seems to work with the old Shader Graph materials.
      https://developers.maxon.net/forum/topic/15819/python-how-to-insert-knots-in-c4d-gradient

      The node editor exposes the inputs I would need, but I just haven't been able to figure out how to write to them.
      alt text

      Any help on this would be very much appreciated. Thank you!

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

        Hello @pislices,

        Welcome to the Maxon developers forum and its community, it is great to have you with us!

        Getting Started

        Before creating your next postings, we would recommend making yourself accustomed with our forum and support procedures. You did not do anything wrong, we point all new users to these rules.

        • Forum Overview: Provides a broad overview of the fundamental structure and rules of this forum, such as the purpose of the different sub-forums or the fact that we will ban users who engage in hate speech or harassment.
        • Support Procedures: Provides a more in detail overview of how we provide technical support for APIs here. This topic will tell you how to ask good questions and limits of our technical support.
        • Forum Features: Provides an overview of the technical features of this forum, such as Markdown markup or file uploads.

        It is strongly recommended to read the first two topics carefully, especially the section Support Procedures: How to Ask Questions.

        About your First Question

        Thank you for reaching out to us. The Nodes API, i.e., the API you are using since you show us the Node Editor, is a Maxon and not a Cinema API, so it uses entities from the maxon and not c4d namespace in Python (you linked to c4d.Gradient article for the old Redshift Xpresso Nodes - which are part of the Cinema API). E.g., the Nodes API uses maxon.GradientInterface and not c4d.Gradient. Under the hood, the Cinema API type is usually just a thin wrapper for the Maxon API type, but that does not really matter for us here.

        What comes on top of this, is that the Nodes API abstracts all data types it uses and decomposes them accordingly into port bundles (a data type) and variadic ports (a list of dynamically addable or removable ports for things such as points, gradient knots, or the layers of a shader). See here for details on these two concepts.

        So, to add/remove or manipulate knots of a gradient, you do not get the data as a whole, modify it, and then write all data back, but manipulate ports which represent individual gradient knots. In short, you get the port bundle which represents the gradient on your node. This port then usually has a child port which is a port bundle which holds all the knots of the gradient. You can add or remove ports form/to that bundle to modify the gradient. To edit a knot, you write to the attributes of the port which represents that knot.

        Graph descriptions offer an abstraction for this not entirely trivial subject (see also the link for variadic ports and port bundles, it also contains some example code for graph descriptions on that subject).

        Cheers,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • pislicesP Offline
          pislices
          last edited by

          Hi @ferdinand,
          I appreciate the reply! I didn't have a chance to update this post until now, but over the weekend I also found the Graph Descriptions Manual you've linked.
          The Scalar Ramp example in there was enough to help me figure out how to implement it with the Ramp node.
          Thank you for your response though, I'm sure it will make things easier if anyone else comes across this subject!

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