Is it possible to delete an Xpresso node using Python within a Redshift material? I am baking an object and when I move it to a new scene file, the user data parameters referenced inside the node are broken so I would like to remove the node.
Hi @Swinn, thanks for reaching out us.
With regard to your question, once you've retrieved the root from the GvNodeMaster, you can traverse the shader graph and considering that a GvNode inherits from a BaseList2D and consequently from GeListNode you can delete it by calling GeListNode::Remove().
Assuming this graph the code below deletes the noise node just by looking, for the sake of simplicity, at its name.
activeMat = doc.GetActiveMaterial()
if activeMat is not None and activeMat.GetType() != 1036224:
print "Active material is not a RedShift one"
outputNode = activeMat[c4d.REDSHIFT_GRAPH_NODES]
if outputNode is None:
print "Output node is not valid"
gvMaster = outputNode.GetNodeMaster()
if gvMaster is None:
print "NodeMaster is not valid"
gvRoot = gvMaster.GetRoot()
if gvRoot is None:
print "Root node is invalid"
currentNode = gvRoot.GetDown()
while currentNode is not None:
if currentNode.GetName() = "RS Noise":
currentNode = currentNode.GetNext()
print "Node removed"