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

    How to set a custom color for a node?

    Cinema 4D SDK
    python 2024
    3
    7
    814
    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.
    • M
      momoko
      last edited by

      It's me again!

      I'm wondering if there is an example to explain how we can use a custom color for a node? the nodes are grey by default but we can change their color

      DunhouD 1 Reply Last reply Reply Quote 0
      • DunhouD
        Dunhou @momoko
        last edited by

        Hi @momoko,

        You should take a look at create_redshift_nodematerial_2024.py, I will show you a custom and easier solution with Renderer lib, see codes[1], you can check how it works but you must have a basic understanding of Node Graph.

        And if you use c4d above 2024.3.0, you are highly suggested to look Graph Description Manual , see codes[2]

        Cheers~
        DunHou

        import c4d, maxon
        from Renderer import Redshift,EasyTransaction
        
        def main() -> None:
            material: c4d.BaseMaterial = Redshift.Material("MyMaterial")
            with EasyTransaction(material) as tr:
                
                surface = tr.GetRootBRDF()
        
                tr.SetShaderValue(
                    surface,
                    "com.redshift3d.redshift4c4d.nodes.core.standardmaterial.base_color" ,
                    maxon.Vector(1,0,0)
                    )
        
                tr.InsertMaterial()
        
        if __name__ == '__main__':
            main()
        
        import maxon
        from maxon import GraphDescription
        
        GraphDescription.ApplyDescription(
            GraphDescription.CreateGraph(name="Basic Example"), {
                GraphDescription.Type: "Output",
                "Surface": {
                    GraphDescription.Type: "Standard Material",
                    "Base/Color": maxon.Vector(1, 0, 0),
                }
            }
        )
        

        https://boghma.com
        https://github.com/DunHouGo

        M 1 Reply Last reply Reply Quote 1
        • M
          momoko @Dunhou
          last edited by

          @Dunhou Thanks but I mean the color of the node itself, not the base color

          DunhouD 1 Reply Last reply Reply Quote 0
          • DunhouD
            Dunhou @momoko
            last edited by Dunhou

            well @momoko

            To change or edit the flag color of a "true node", you need to modify the "maxon.NODE.BASE.COLOR" attribute.

            Cheers~
            DunHou

            https://boghma.com
            https://github.com/DunHouGo

            M 1 Reply Last reply Reply Quote 0
            • M
              momoko @Dunhou
              last edited by

              @Dunhou Thank you. Do you know how I can see what kind of values I can set for it?

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

                Hey @momoko,

                thank you for reaching out to us and thank you @Dunhou for all the community answers you all provide!

                @Dunhou's second answer would be the solution, you must to run myGraphNode.SetValue("maxon.NODE.BASE.COLOR", maxon.Color(1, 0, 0)). With graph descriptions you can just type out the things you want to do, under Graph Descriptions: Callbacks I have shown how to color in title bars. But you would not have to use a callback, you can also type out Basic/Color manually for each node.

                As data types are maxon.Color and maxon.Vector or their four component variants fine. Graph descriptions also allow you to use tuples or c4d.Vector and will convert the data for you.

                Cheers,
                Ferdinand

                MAXON SDK Specialist
                developers.maxon.net

                M 1 Reply Last reply Reply Quote 0
                • M
                  momoko @ferdinand
                  last edited by

                  @ferdinand You are amazing! Thanks

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