hi there, I actually did sort this out in a very round about way with some "vibe coding". this was for a mapp creation project I am working where I am displaying various eras of map onto 20km grids (so as not to kill the viewport functionality). have a look at the below and let me know if this is a solid approach or if there was a better way:
import c4d
import maxon
def main():
era = "INSERT_YOUR_ERA_HERE"
basePath = "INSERT_YOUR_PATH_HERE"
prefix = f"map_{era}_tile_20k_"
extension = ".tif"
doc = c4d.documents.GetActiveDocument()
if doc is None:
return
nodeSpaceId = maxon.Id("com.redshift3d.redshift4c4d.class.nodespace")
textureNodeId = maxon.Id("com.redshift3d.redshift4c4d.nodes.core.texturesampler")
for mat_index in range(1, 9):
mat_name = f"column_{mat_index:02d}"
mat = doc.SearchMaterial(mat_name)
if not mat:
print(f"Material {mat_name} not found.")
continue
nodeMat = mat.GetNodeMaterialReference()
if nodeMat is None:
print(f"{mat_name} is not a node material.")
continue
graph = nodeMat.GetGraph(nodeSpaceId)
if graph.IsNullValue():
print(f"No Redshift graph for {mat_name}.")
continue
textureNodes = []
maxon.GraphModelHelper.FindNodesByAssetId(graph, textureNodeId, False, textureNodes)
with graph.BeginTransaction() as transaction:
for node in textureNodes:
node_name = node.GetValue(maxon.NODE.BASE.NAME)
if not node_name:
print(f"Unnamed node in {mat_name}, skipping.")
continue
node_name = str(node_name)
try:
local_index = int(node_name)
except:
print(f"Non-numeric node name '{node_name}' in {mat_name}, skipping.")
continue
global_index = (mat_index - 1) * 11 + local_index
filename = f"{prefix}{global_index:03d}{extension}"
full_path = basePath + filename
tex0 = node.GetInputs().FindChild(
"com.redshift3d.redshift4c4d.nodes.core.texturesampler.tex0"
)
if tex0.IsNullValue():
print(f"No tex0 on node '{node_name}' in {mat_name}")
continue
pathPort = tex0.FindChild("path")
if pathPort.IsNullValue():
print(f"No path port on node '{node_name}' in {mat_name}")
continue
pathPort.SetDefaultValue(maxon.Url(full_path))
print(f"{mat_name} → Node '{node_name}' set to {full_path}")
transaction.Commit()
c4d.EventAdd()
if __name__ == "__main__":
main()