Hi, I want to change all settings of thickness in Contour node of all toon materials?
Any idea of how to do this?
thanks
import c4d
from c4d import gui
def traverse_nodes(graph, ext_value, int_value):
"""Recursively search nodes in a graph."""
for node in graph.GetNodes():
try:
node_id = node.GetDefinition().GetID()
except:
node_id = None
# Look for the RS Contour node by its ID string
if node_id == "com.redshift3d.redshift4c4d.nodes.core.contour":
print(f"✅ Found Contour node in: {node.GetName()}")
node.SetParameter("com.redshift3d.redshift4c4d.nodes.core.contour.externalthickness", ext_value, c4d.DESCFLAGS_SET_0)
node.SetParameter("com.redshift3d.redshift4c4d.nodes.core.contour.internalthickness", int_value, c4d.DESCFLAGS_SET_0)
# Check if the node contains subgraphs
for port in node.GetInputs() + node.GetOutputs():
subgraph = port.GetNodeGraph()
if subgraph:
traverse_nodes(subgraph, ext_value, int_value)
def main():
# Get user values
ext_str = gui.InputDialog("External Thickness", "1.0")
int_str = gui.InputDialog("Internal Thickness", "1.0")
try:
ext_value = float(ext_str)
int_value = float(int_str)
except ValueError:
gui.MessageDialog("Invalid number input.")
return
# Loop through all materials
for mat in doc.GetMaterials():
if not mat.CheckType(1036224): # Redshift material
continue
node_material = mat.GetNodeMaterialReference()
if not node_material:
continue
# Try all available graphs inside the material
graphs = node_material.GetGraphs()
if not graphs:
continue
print(f"Scanning material: {mat.GetName()}")
for graph in graphs:
traverse_nodes(graph, ext_value, int_value)
c4d.EventAdd()
if __name__ == "__main__":
main()