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

    Unusual Remove() Results

    Cinema 4D SDK
    r20 python
    3
    4
    805
    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.
    • B
      bentraje
      last edited by

      Hi,

      I'm trying to clone an object and delete the tags attached on the original object.
      Here is the code:

      # Select an editable object
      def main():
      
          # Copy original object
          obj = op.GetClone(c4d.COPYFLAGS_NO_HIERARCHY)
          doc.InsertObject(obj)
      
          # Remove Tags
          tags = obj.GetTags()
          for tag in tags:
              tag.Remove()
          
          c4d.EventAdd()
      

      The problem is the Remove Tags section deletes not only tags but also the points. So even though the object is in the hierarchy, it doesn't contain any points.

      Is there a way around this? Thank you

      1 Reply Last reply Reply Quote 0
      • C4DSC
        C4DS
        last edited by

        The geometry of an object is stored in hidden tags (points and polygons, namely)
        These are not visible, nor selectable ... and thus can theoretically not be deleted by user. But you still can access these via Python, or C++. As such, when removing all tags you also remove critical ones, that are needed by the object in order to exist.

        1 Reply Last reply Reply Quote 2
        • B
          bentraje
          last edited by

          @C4DS

          Thanks for the response. Just revised the section and it works as expected

              # Remove Tags
              tags = obj.GetTags()
              for tag in tags:
                  if tag.GetType() == 5617: # Tangent Tag
                      pass
                  elif tag.GetType() == 5600: # Point Tag
                      pass
                  elif tag.GetType() == 5604: # Polygon Tag
                      pass
                  else:        
                      tag.Remove()
          

          Thanks for the help. Have a great day ahead!

          1 Reply Last reply Reply Quote 0
          • ManuelM
            Manuel
            last edited by Manuel

            hello,

            just a step to confirm @C4DS answer and if you look again at @r_gigante answer in this post it will make now fully sense.

            regarding your code i will go like this just to be a bit shorter and easier if i want to add or remove a tag from the list.

                safeTagList = [5617, 5600, 1604]
                
                tags = node.GetTags()
                for tag in tags:
                    if tag not in safeTagList: 
                        tag.Remove()
            

            Cheers
            Manuel

            MAXON SDK Specialist

            MAXON Registered Developer

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