Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    delete Redshift node

    Cinema 4D SDK
    2
    3
    774
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • SwinnS
      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.Screen Shot 2020-05-23 at 6.40.34 AM.png

      1 Reply Last reply Reply Quote 0
      • r_giganteR
        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.
        53b3f18a-c039-485d-8484-e85cc594f96c-image.png

        ...
            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"
        ...
        

        Best, Riccardo

        1 Reply Last reply Reply Quote 0
        • SwinnS
          Swinn
          last edited by

          Cool! Thanks. 🙂

          1 Reply Last reply Reply Quote 0
          • First post
            Last post