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

    Create RS Standard Material instead of RS Material

    Cinema 4D SDK
    2023 python
    2
    6
    926
    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.
    • P
      pim
      last edited by pim

      The code below creates a RS Material Node.

      material: c4d.BaseMaterial = c4d.BaseMaterial(c4d.Mmaterial)
       if not material:
           raise MemoryError(f"{material = }")
      
       nodeMaterial: c4d.NodeMaterial = material.GetNodeMaterialReference()
       graph: maxon.GraphModelRef = nodeMaterial.AddGraph(maxon.Id("com.redshift3d.redshift4c4d.class.nodespace"))
       if graph.IsNullValue():
           raise RuntimeError("Could not add standard graph to material.")
       else:
           #print ("Success AddGraph")
           pass
      

      1d56d716-6323-4fd8-9788-0e36169f202d-image.png
      How can add I a RS Standard Material instead of a RS Material?

      a9f9d053-c4cd-4a58-abf9-5d58f87f083d-image.png

      1 Reply Last reply Reply Quote 0
      • ManuelM
        Manuel
        last edited by

        Hi,

        With the update 2023.1 we have introduced the function CreateDefaultGraph.

        To resume the current situation for redshift:

        • AddGraph will call the function that is registered within the nodespace data for the ID maxon::nodes::NODESPACE::CREATEMATERIALGRAPHFUNC
        • CreateDefaultGraph will create the Standard material
        • CreateEmptyGraph will create an empty graph

        Creating an empty graph allow you to populate it the way you want. You can create the nodes and the connection yourself. If you create yourself the end node and the standard node. You might want to define the path of those nodes in the NimbusRef.
        To retrieve the NimbusRef you can use the function GetNimbusRef from the BaseList2D object. From there you can use SetPath to define the path for the end node.
        The Id maxon.NIMBUS_PATH.STARTNODE is interesting as this define the node that will be displayed in the Attributs Manager when you select the material.

        The easiest way to create a standard materiel is to use CreateDefaultGraph.

        Cheers,
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

        1 Reply Last reply Reply Quote 0
        • P
          pim
          last edited by

          Great, thank you.

          1 Reply Last reply Reply Quote 0
          • P
            pim
            last edited by

            Could you elaborate a bit more on NimbusRef?
            Why and when to use it.

            1 Reply Last reply Reply Quote 0
            • ManuelM
              Manuel
              last edited by Manuel

              For an external user, NimbusRef can be seen as a hook to attach any GraphSystem to a BaseList2D. Most of the needed functionalities have been added to the BaseList2D but some remain. Most of the time you do not need it. If you use CreateDefaultGraph you do not need it for example.

              Cheers,
              Manuel

              MAXON SDK Specialist

              MAXON Registered Developer

              1 Reply Last reply Reply Quote 0
              • P
                pim
                last edited by

                Ok, thank you.

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