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

    String values for the "FindChild"?

    Cinema 4D SDK
    python r25
    2
    13
    1.3k
    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.
    • B
      bentraje
      last edited by

      @Manuel

      Thanks for the response. And yes, your answer does present the ID of the Path (or the ID of the Port?) which I guess the one needed for the connect method (Well my recent threads is just really to have connect ports of two nodes together because I can't find a decent example)

      Anyhow, what I'm really after is the
      String values for the "FindChild"?

      The reason why I prefer it over the com.redshift3d.redshift4c4d.nodes.core.fresnel.fresnel_useior is because that one is so verbose.
      I just want to use FindChild(fresnel_useior). Much clearer to read.

      Is this still possible? I tried checking the Resource Editor for some clues.
      I tried

      FindChild(perp_color)
      FindChild(Perpendicular Color`)

      Am I looking at the wrong areas?

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

        There is no string they are just IDs. The string is converted to an maxon::Id

        You can not use fresnel_useior because this is not the ID of the port. The ID of the port is com.redshift3d.redshift4c4d.nodes.core.fresnel.fresnel_useior (and yes this is a bit verbose)

        The symbol for this ID (at least in c++) should be redshift3d::redshift4c4d::nodes::core::fresnel::fresnel_useior but again they are not exposed.

        @ferdinand created a nice c++ example about connecting ports in redshift and using the texture node. You can see there that he first search for the port bundle and then, search for the file port.

            // Retrieve the "Filename" port of the texture node.
            maxon::GraphNode tex0InportRust = rustTextureNode.GetInputs().FindChild(
              maxon::Id("com.redshift3d.redshift4c4d.nodes.core.texturesampler.tex0")) iferr_return;
            if (!tex0InportRust.IsValid())
              return maxon::UnexpectedError(MAXON_SOURCE_LOCATION, "Failed to access port."_s);
         
            // The "Filename" port is a port bundle which consists out of two sub-ports, the "path" and the
            // "layer" port. The texture URL is written into the "path" sub-port.
            maxon::GraphNode pathInportRust = tex0InportRust.FindChild(maxon::Id("path")) iferr_return;
            if (!pathInportRust.IsValid())
              return maxon::UnexpectedError(MAXON_SOURCE_LOCATION, "Failed to access port."_s);
         
            // Set the path of the rust texture node to the URL of the rust texture asset.
            pathInportRust.SetDefaultValue(rustTextureUrl) iferr_return;
        

        Cheers,
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

        1 Reply Last reply Reply Quote 0
        • B
          bentraje
          last edited by

          @Manuel

          RE: There is no string they are just IDs.
          Ah. I guess I was misguided.
          I was thinking the FindChild spits out the verbose id.
          For the sake of argument, why did the modify_port_value.py script used a string value?
          colordePort = bsdfNodeInputs.FindChild("color")
          That's the basis of my confusion lol

          RE: nice c++ example
          Missed this one out. Thanks! At least now I have a base example to check.

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

            @bentraje said in String values for the "FindChild"?:

            For the sake of argument, why did the modify_port_value.py script used a string value?

            When I wrote the nodes examples, the symbols were not necessarily available, and/or public. The node API is now more stable, i need to update some examples.

            Cheers,
            Manuel

            MAXON SDK Specialist

            MAXON Registered Developer

            1 Reply Last reply Reply Quote 0
            • B
              bentraje
              last edited by

              @Manuel

              Thanks for the response but it still gives me error though.

              I tried this one:

              fresnel_port = node.FindChild(maxon.Id("com.redshift3d.redshift4c4d.nodes.core.fresnel.fresnel_useior"))

              It gives me an error of
              TypeError: unable to convert builtins.NativePyData to @net.maxon.datatype.internedid

              or is there a different way to access the port?

              1 Reply Last reply Reply Quote 0
              • B
                bentraje
                last edited by

                I also tried the actual string id

                fresnel_port = node.FindChild("com.redshift3d.redshift4c4d.nodes.core.fresnel.fresnel_useior")
                it gives me null.

                All of the examples in the github does not access one port (it access all ports) except for the modify_port_value_r24.py so I'm not sure how to proceed.

                1 Reply Last reply Reply Quote 0
                • B
                  bentraje
                  last edited by

                  Example in this thread is using a generic string too instead of an ID so can't really refer directly

                  https://developers.maxon.net/forum/topic/14101/how-to-show-nodes-api-nodes-in-the-node-editor/4

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

                    Hi,

                    sorry, we must define which version you want to use. Depending on the version this can vary a lot. On some version, functions are in a different class, Strings are not converted to maxon::Id. Using python for the node API was a bit limited in r25.

                    Cheers,
                    Manuel

                    MAXON SDK Specialist

                    MAXON Registered Developer

                    B 1 Reply Last reply Reply Quote 0
                    • B
                      bentraje @Manuel
                      last edited by

                      @manuel

                      gotcha sorry about that.
                      what are my options for R25? (i.e. how can I use the FindChild with the Maxon Id ? )

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

                        hi,

                        Something like this should works in R25. This will find the base_color ports of the redshift material. The Material must be a standard material and the standard node must be selected.

                        import c4d
                        import maxon
                        from c4d import gui
                        from maxon.frameworks import nodes
                        
                        # Main function
                        def main():
                            mat = doc.GetActiveMaterial()
                            if mat is None:
                                raise ValueError("can't retrieve the selected material")
                        
                            nodespaceId = c4d.GetActiveNodeSpaceId()
                            nodemat = mat.GetNodeMaterialReference()
                            graph = nodemat.GetGraph(nodespaceId)
                        
                            def PrintNode(node):
                                colorNode = node.GetInputs().FindChild("com.redshift3d.redshift4c4d.nodes.core.standardmaterial.base_color")
                                print (colorNode)
                                return True
                        
                            graph.GetSelectedTrueNodes(PrintNode)
                            # With newest version of cinema 4D,  the function to retrieve the selected nodes was moved to another class so instead use the new one.
                            #maxon.GraphModelHelper.GetSelectedNodes(graph, maxon.NODE_KIND.ALL_MASK, PrintNode)
                        # Execute main()
                        
                        if __name__=='__main__':
                            main()
                        

                        Cheers,
                        Manuel

                        MAXON SDK Specialist

                        MAXON Registered Developer

                        1 Reply Last reply Reply Quote 1
                        • B
                          bentraje
                          last edited by

                          @Manuel

                          Gotcha. Thanks for the clarification.
                          Sorry for the trouble.

                          Works as expected. Will close this thread now.

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