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

    Editing RS Nodes with Python

    Cinema 4D SDK
    python
    2
    5
    888
    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.
    • C
      cgweasel
      last edited by

      Hi,

      i have been wrapping my head around it, but I cannot find anything. Or maybe I am thinking the wrong way.

      What i want it to get selected Nodes out of my RS Material to edit the Parameters. But I cannot find anything in the SDK. Could not get anything out of the GvNode.

      What I would like the script to do:

      I want to select texture Nodes in my Materials and the script will change the color space to file-IO -> RAW

      Thanks and happy holidays 🦌

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

        Hi @cgweasel, to retrieve the selected node, like all BaseList2D (BaseOject,BaseTag,BaseMaterial, etc...) you can know there selection state with the method node.GetBit(c4d.BIT_ACTIVE).

        So find bellow the complete code to do what you want:

        import c4d
        
        
        def main():
            # Checks if selected material is valid
            mat = doc.GetActiveMaterial()
            if not mat or not mat.CheckType(1036224) :
                raise ValueError("There is no xpresso redshift material selected")
            
            # Retrieve the output nodes, which is also the first node in the node hierarchy. 
            # Therefor we can iterate them as usual BaseList2D
            node = mat[c4d.REDSHIFT_GRAPH_NODES]
            while node:
                # Check if this is a texture node and its selected
                if node[c4d.GV_REDSHIFT_SHADER_META_CLASSNAME] == 'TextureSampler' and node.GetBit(c4d.BIT_ACTIVE):
                    # Set to Raw, to know the Id and the value I left click on the Filename parameter, User Interface -> Show SubChannel
                    # Then I dragged the ColorSpace parameter to the python console
                    node[c4d.REDSHIFT_SHADER_TEXTURESAMPLER_TEX0,c4d.REDSHIFT_FILE_COLORSPACE] = "RS_INPUT_COLORSPACE_RAW"
                    
                node = node.GetNext()
        
            c4d.EventAdd()
        
        if __name__=='__main__':
            main()
        

        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        C 1 Reply Last reply Reply Quote 0
        • C
          cgweasel @m_adam
          last edited by

          Hi Maxime,

          thank you very much. On a Xpresso Material, this works just fine. Unfortunately, I only use Node Materials. I know the type of those Materials is 5703, but it seems that everything else is not responding to nodes.

          Thanks for the tipp with the sub-channels. Awesome. But this also does not work with nodes 😞

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

            Hi @cgweasel hope you had a nice Christmas time 🙂

            Regarding your question, this has been answered in this post Change the ColorSpace of Redshift Texture Node?
            Then you can find example about nodes graph in our GitHub repository, And I would advice you to look at modify_port_value.

            I think with that you have all the information needed to make it work, if you struggle please let me know and I will be happy to help you. For the future please specify which node system you are using, since you mentioned GvNode I guessed that you used xpresso.

            Cheers,
            Maxime.

            MAXON SDK Specialist

            Development Blog, MAXON Registered Developer

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

              Hello @cgweasel,

              without further questions or postings, we will consider this topic as solved by Friday 02/06/2023 and flag it accordingly.

              Thank you for your understanding,
              Maxime.

              MAXON SDK Specialist

              Development Blog, MAXON Registered Developer

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