Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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

    Undo of inserting a tag

    Cinema 4D SDK
    python
    3
    4
    532
    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.
    • P
      pim
      last edited by s_bach

      I have a tag plugin where I move tags from one object to another.
      I tried several Undo types, but I cannot get it working.
      What to do?

                  childTags = child.GetTags()
                  ....
                  for childTag in childTags:
                      #doc.AddUndo(c4d.UNDOTYPE_CHANGE, object)
                      doc.AddUndo(c4d.UNDOTYPE_HIERARCHY_PSR, object)
                      object.InsertTag(childTag)
                      #doc.AddUndo(c4d.UNDOTYPE_NEW, object)
      
      1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand
        last edited by ferdinand

        Hi,

        undo-steps for inserting objects have to be added after the the object has been inserted; the appropriate flag is then c4d.UNDOTYPE_NEW. Could you describe in more detail what is not working?

        Cheers,
        zipit

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • S
          s_bach
          last edited by s_bach

          Hello,

          an undo-step has to start with StartUndo() and must end with EndUndo(). In between, you can add operations to that undo-step with AddUndo(). As @zipit has shown, the undo-operation for adding something to the document is c4d.UNDOTYPE_NEW.

          doc.StartUndo()
          
          ttag = c4d.TextureTag()
          op.InsertTag(ttag)
          
          doc.AddUndo(c4d.UNDOTYPE_NEW, ttag)
          doc.EndUndo() 
          

          See also Undo System Manual.

          best wishes,
          Sebastian

          MAXON SDK Specialist

          Development Blog, MAXON Registered Developer

          1 Reply Last reply Reply Quote 0
          • S
            s_bach
            last edited by

            Also, if you want to move a tag, you first have to remove it from the original object. So you don't insert, you change the position of the tag in the scene graph.

            doc.StartUndo()
            
            doc.AddUndo(c4d.UNDOTYPE_CHANGE, tag)
            
            tag.Remove()
            op.InsertTag(tag)
            
            doc.EndUndo() 
            

            MAXON SDK Specialist

            Development Blog, MAXON Registered Developer

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