delete Redshift node
Swinn last edited by Swinn
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.
r_gigante last edited by
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" return outputNode = activeMat[c4d.REDSHIFT_GRAPH_NODES] if outputNode is None: print "Output node is not valid" return gvMaster = outputNode.GetNodeMaster() if gvMaster is None: print "NodeMaster is not valid" return gvRoot = gvMaster.GetRoot() if gvRoot is None: print "Root node is invalid" return currentNode = gvRoot.GetDown() while currentNode is not None: if currentNode.GetName() = "RS Noise": currentNode.Remove() break currentNode = currentNode.GetNext() print "Node removed" ...