Unusual Remove() Results



  • 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



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



  • @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!



  • 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


Log in to reply