Hi @sortsovs once you have the node, you need to retrieve the appropriate port. Be careful as some port can be nested.
Then once you have the correct port, you need to call GraphNode.SetDefaultValue.
When calling SetDefaultValue it is important to pass a maxon data as the current Python system is not able to automatically guess the expected result.
Find bellow an example to create a Redshift Material with a Texture Node with a custom path and name.
import c4d
import maxon
REDSHIFT_NODESPACE_ID = maxon.Id("com.redshift3d.redshift4c4d.class.nodespace")
def CreateTextureNode(gr: maxon.GraphModelRef, nodeName: str, texturePath: str, isLinear:bool=False) -> maxon.GraphNode:
# Start a transaction to inform the graph that a modification is going to happen
with gr.BeginTransaction() as transaction:
# Create a Redshift Texture Node and rename it
textureNodeId = maxon.Id("com.redshift3d.redshift4c4d.nodes.core.texturesampler")
texNode = gr.AddChild("", textureNodeId, maxon.DataDictionary())
texNode.SetValue("net.maxon.node.base.name", maxon.String(nodeName))
# Retrieve path and gammage override port
path = texNode.GetInputs().FindChild("com.redshift3d.redshift4c4d.nodes.core.texturesampler.tex0").FindChild("path")
gammaOverride = texNode.GetInputs().FindChild("com.redshift3d.redshift4c4d.nodes.core.texturesampler.tex0_gammaoverride")
# Define the value stored by the node for these port when no connection exist
gammaOverride.SetDefaultValue(maxon.Bool(isLinear))
path.SetDefaultValue(maxon.Url(texturePath))
# Push the change to the graph
transaction.Commit()
return texNode
def main() -> None:
# Create a BaseMaterial in the active document
rsMat = c4d.BaseMaterial(c4d.Mmaterial)
doc.InsertMaterial(rsMat)
# Retrieve it node material part and create a Redshift Graph
nMat = rsMat.GetNodeMaterialReference()
nMat.AddGraph(REDSHIFT_NODESPACE_ID)
gr = nMat.GetGraph(REDSHIFT_NODESPACE_ID)
# Create a texture node
albedoTexNode = CreateTextureNode(gr, "Albedo", r"C:/PathToATexture.jpg")
c4d.EventAdd()
if __name__ == '__main__':
main()
Cheers,
Maxime.