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

    Moving\Deleting nodes with Python

    Cinema 4D SDK
    python r20
    2
    3
    836
    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.
    • S
      sheilan
      last edited by sheilan

      Hello,

      I've got a GvNode that I can rename and control, but I'm not sure how I can delete or move it's position in Xpresso.

      Thanks in advance,
      Sheilan.

      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by

        Hi @sheilan,
        Moving Xpresso node have been discussed here, same warning as Andreas did, ID may change in the future and break your stuff since there is no symbols for theses data.

        Regarding how to delete a GvNode, as you may have seen, GvNode inherit from BaseList2D which inherit from GeListNode, so you can use the GeListNode.Remove method.

        Here an example:

        import c4d
        
        
        def main():
            # Checks if selected object is valid
            if op is None:
                raise ValueError("op is none, please select one object.")
        
            # Retrieves the xpresso Tag
            xpressoTag = op.GetTag(c4d.Texpresso)
            if xpressoTag is None:
                raise ValueError("Make sure the selected object get an Xpresso Tag.")
        
            # Retrieves the node master
            gvNodeMaster = xpressoTag.GetNodeMaster()
            if gvNodeMaster is None:
                raise RuntimeError("Failed to retrieves the Node Master.")
        
            # Retrieves the Root node (the Main XGroup) that holds all others nodes
            gvRoot = gvNodeMaster.GetRoot()
            if gvRoot is None:
                raise RuntimeError("Failed to retrieves the Root Node.")
        
            # Iterates overs all nodes of this root node.
            firstNode = gvRoot.GetDown()
            if firstNode is None:
                raise RuntimeError("Failed to retrieves the First Node.")
        
            # Defines Y size
            firstNode.GetDataInstance().GetContainerInstance(1001).GetContainerInstance(1000)[109] = 50
        
            # Defines X size
            firstNode.GetDataInstance().GetContainerInstance(1001).GetContainerInstance(1000)[108] = 100
        
            # Defines the Y position
            firstNode.GetDataInstance().GetContainerInstance(1001).GetContainerInstance(1000)[101] = -200
        
            # Defines the X position
            firstNode.GetDataInstance().GetContainerInstance(1001).GetContainerInstance(1000)[100] = -200
        
            # GvNode is a GeListNode so you can simply use Remove
            firstNode.Remove()
        
            # Updates Cinema 4D
            c4d.EventAdd()
        
        
        if __name__ == '__main__':
            main()
        

        If you have any questions, let me know.
        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        1 Reply Last reply Reply Quote 2
        • S
          sheilan
          last edited by

          Works perfectly. Thanks!

          1 Reply Last reply Reply Quote 0
          • M m_adam referenced this topic on
          • First post
            Last post