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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Directly create Redshift standard surface for RS node space

    Cinema 4D SDK
    s26 python windows
    2
    5
    676
    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.
    • DunhouD
      Dunhou
      last edited by

      Hello, Is there possibale to create a standard surface directly in new node editor (not expresso) ?

      When I create a Redshift node material it always return a old RS material by default. now my solution is add a new standard surface shader and remove the old RS material , Is there a smart way to do this ?

      (by the way, I know I can use CallCommand fuction , but I working a a custom API with Redshift , so I need a controllable way )

      Here is a little lines I do this :

      import c4d
      import maxon
      
      StandardMaterialAssetID = maxon.Id("com.redshift3d.redshift4c4d.nodes.core.standardmaterial")
      StandardOutputPortID = maxon.Id("com.redshift3d.redshift4c4d.nodes.core.standardmaterial.outcolor")
      OutputMaterialAssetID = maxon.Id("com.redshift3d.redshift4c4d.node.output")
      OutputSurfacePortID = maxon.Id("com.redshift3d.redshift4c4d.node.output.surface")
      
      
      def CreateNodeMat(matname):
          mat = c4d.BaseMaterial(c4d.Mmaterial)
          nodeMaterial = mat.GetNodeMaterialReference()
          nodespaceId = maxon.Id("com.redshift3d.redshift4c4d.class.nodespace")
          addedGraph = nodeMaterial.AddGraph(nodespaceId)
          nimbusRef = mat.GetNimbusRef(nodespaceId)
          graph = nimbusRef.GetGraph()
          endNodePath = nimbusRef.GetPath(maxon.NIMBUS_PATH.MATERIALENDNODE)
          endNode = graph.GetNode(endNodePath)
          predecessor = list()
          maxon.GraphModelHelper.GetDirectPredecessors(endNode, maxon.NODE_KIND.NODE, predecessor)
          bsdfNode = predecessor[0]
          bsdfNodeInputs = bsdfNode.GetInputs()
      
          with graph.BeginTransaction() as transaction:
              STM = graph.AddChild('', StandardMaterialAssetID, maxon.DataDictionary())
              inPort = endNode.GetInputs().FindChild("com.redshift3d.redshift4c4d.node.output.surface")
              outPort = STM.GetOutputs().FindChild("com.redshift3d.redshift4c4d.nodes.core.standardmaterial.outcolor")
              bsdfNode.Remove()
              outPort.Connect(target = inPort, modes=maxon.WIRE_MODE.NORMAL, reverse=False)
              transaction.Commit()
          doc.InsertMaterial(mat)
          mat.SetName(matname)
      
      if __name__ == "__main__":
          CreateNodeMat("RS Node STD")
      

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

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

        Hi,

        When you call AddGraph, the delegate function registered for the nodespace to create a material is executed. That is why it create a default redshift node material with the default endNode and the default RS Material node.

        The only way to do it for now is exactly what you are doing.

        One remark i should have comment in our examples,

        addedGraph = nodeMaterial.AddGraph(nodespaceId)
        nimbusRef = mat.GetNimbusRef(nodespaceId)
        graph = nimbusRef.GetGraph()
        

        addedGraph is the same as graph, nimbusRef are sometimes useful, but if you are just manipulating existing graph, they are not.

        Cheers,
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

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

          @m_magalhaes Thanks

          That' ok , Maybe I should create a specific function to do this task😊

          And your tips:

          graph1 = nodeMaterial.AddGraph(nodespaceId)
          graph2 = mat.GetNodeMaterialReference().GetNimbusRef(nodespaceId).GetGraph()
          

          gragh1 is the same as gragh2 ? In Chinese laguage the word NimbusRef is hard to understand , I read the python document , is that mean a list a material's node space ? like :Mat[arnold spcae, redshift space]

          So the gragh2 fuction get the redshift spcae and get the gragh nodes for redshift only ?

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

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

            hi,

            A material object inherit from BaseList2D object. That BaseList2D can store multiple graphs, one for each space. NimbusBaseInterface manages NodesGraphModelInterface. From an external point of view, the NimBusRef is just a hook to attach a NodeGraph to a Material. Internally, it manages the technical aspect of a NodeGraphModel.

            NodeMaterial.GetGraph(self, spaceId)
            NodeMaterial.AddGraph(self, spaceId)
            NimbusBaseInterface.GetGraph()
            all those functions return the same maxon.NodesGraphModelRef

            Cheers,
            Manuel

            MAXON SDK Specialist

            MAXON Registered Developer

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

              @m_magalhaes
              Thanks for that explain.

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

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