Solved String values for the "FindChild"?

@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?

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

@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.

@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

@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?

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.

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

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

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

@manuel

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

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

@Manuel

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

Works as expected. Will close this thread now.