Delete Third-Party-Tags?



  • Hi there,

    I created this script where I delete every third-party-tag from the current document.

    However I was wondering if it's not even simpler to just delete tags with a certain "id-threshold".

    What's the first/smallest ID that third-party-tags or plugin-ids can have?

    So one can basically: Delete Tag if tag-id is bigger than threshold

    Thanks,
    Lasse



  • Hi,

    plugin ids should start at ID 1E6. The problem is, I am not quite sure that MAXON has never used any of these for their native tags, so you might filter out native stuff. To investigate that you could either check the tag types in the Python docs or, alternatively, grep the resource folder.

    A less risky, but also less future proof approach would be to compile a list of all native tag IDs, again, the tag types in the Python docs and greping the resource folder would probably proof useful for that. I am not sure though, if the tag types list is complete (these id lists have a tendency to be a bit spotty). This would obviously have to updated once MAXON adds new tags, hence the lack of future proofness.

    Cheers,
    zipit



  • There are lots of internal plugins that use the numbers generated from the plugincafe.

    A better solution would be to find the tags in the document and then check what plugin it belongs to and if it is not located in the modules folder in the installation folder of C4D then it is a 3rd party one.

    Not sure why you want to remove the tags though.



  • hi,

    we have some IDs there so it's not a good idea to based your choice on that.

    Thanks @kbar for the solution, that's probably the best for now.
    There's one issue, python plugins. We have some (for team render) but there's no Tag. For python plugins, GetFilename return only the name of the plugin.
    We are going to have a look at it to fix that. So for the futur it should be ok.

    import c4d
    from c4d import gui
    # Welcome to the world of Python
    
    # Main function
    def main():
        tags = op.GetTags()
        removeTag = []
        for tag in tags:
            tagID = tag.GetType()
            plugin =  c4d.plugins.FindPlugin(tagID)
            if plugin is None:
                tag.Remove()
            # python plugin doesn't return any filepath, just the name, so there's no corelibs in the path
            # We have some python plugins (teamrender) but none are tags. (ATM ??)
            elif 'corelibs' in plugin.GetFilename():
                print "corelibs"
            else:
                
                tag.Remove()
        c4d.EventAdd()
    
    # Execute main()
    if __name__=='__main__':
        main()
    

    Cheers,
    Manuel



  • Hi,

    There's one issue, python plugins.

    shouldn't the native Python plugins have their file path attached to them via their __file__ attribute of the module? At least that is the case with normal Python modules, never bothered to check if Cinema's Python, which can be weird sometimes, deviates here from the default behaviour with its pyp files.

    So the plan would be to use Cinema's internal method, test the returned value for path validity and then optionally fall back to the attribute. I cannot test it, because I have no Cinema atm.

    Cheers,
    zipit



  • hi,

    I didn't tested it, but that's probably the result of the c++ function. So fixing it for the c++ function will fix it for python.
    I don't know if you can access easily __file__ from c++ and python's object.

    Cheers,
    Manuel