Jump to content
Sign in to follow this  
Muybridge

Select all tags by tag type

Recommended Posts

Hi.

Probably a pretty basic question: Is there a way to select all tags in a scene that are of the same type at once? Can't find the right python command 😕

Thanks

Nick

Share this post


Link to post

I think it´s not posible with just single command. Script/code must compare all tags applied on object with your wished tag and then iterate thru all objects in the scene.

So, it´s just few lines of code not just single one command imho.

...but maybe I´m mistaken and there is some magic word 😉

 

btw, do you want to create some script?

If not, simply use filter in OM.

https://www.dropbox.com/s/dk69s9x2il1reec/select_the_same_tag.png?dl=0

Share this post


Link to post
  • Topic Author
  • Author of the topic Posted

    Thank you for the hint. But I need the selection as part of a script so the om filter won't work for me.

     

    Still wishing for the magic word ;) Checking every object in the scene for a specific tag seems like the complicated way to do it but maybe you're right ;)

    Share this post


    Link to post

    @Muybridge

    RE: Checking every object in the scene for a specific tag seems like the complicated way to do it but maybe you're right 😉

    Yes, that logic is right. Here's a sample code that stores all phong tags of a scene in a list. Not necessarily select. Selecting is not necessary to modify the objects and it is just unnecessary overhead

     

    import c4d
    from c4d import gui
    
    # Get all tag phong tags and store it in a list
    
    def recurse_hierarchy(op):
        filter_tags = []
        while op:
        
            print op.GetName()
            recurse_hierarchy(op.GetDown())
            
            tag_list = op.GetTags()
            for tag in tag_list:
                if tag.GetType() == 5612: # Change this to your tag type
                    filter_tags.append(tag)
                    
            op = op.GetNext()
            
        return filter_tags
    
    # Execute main()
    if __name__=='__main__':
        phong_tags = recurse_hierarchy(doc.GetFirstObject())

     

    Share this post


    Link to post
  • Topic Author
  • Author of the topic Posted

    Thank you. I have to go trough your script step by step to really understand it and lern something 🙂 I thing selecting the tags will be a part I need, because in the end I wan't to bake the animation that's on them and because of limited scripting skills I thought about using the bake objects command. That solution would depend on selected objects I guess.

    But step by step 😉 I'm right in the middle of it.

    Share this post


    Link to post

    what are you trying to achieve ? Can you explain a bit more ?

    Share this post


    Link to post
  • Topic Author
  • Author of the topic Posted

    Ok so let me explain it a little bit further. I need a script to bake all the posemorph tags in the scene to export animated characters to unity.

     

    The following script does that and while I'm sure that's a pretty dirty workaround it seems to fullfill its purpose.

     

    import c4d
    from c4d import gui
    
    layer_list = []
    
    c4d.CallCommand(12113, 12113) # deselect All
    
    def prepareLayers(layer_root):
        
        
        layer = layer_root.GetDown()       
    
        while layer:
    
            prepareLayers(layer)
            layer_list.append(layer)
            layer = layer.GetNext()
            
        
        print (layer_list)
        
        for x in layer_list:
            x.SetLayerData(doc, {'manager':True})
            x.SetLayerData(doc, {'locked':False})  
        
        #print ("done")
              
        c4d.EventAdd()
    
    def recurse_hierarchy(op):
    
        while op:
            
            recurse_hierarchy(op.GetDown())
            
            tag_list = op.GetTags()
            for tag in tag_list:
                if tag.GetType() == 1024237: # ID = PoseMorphTag
                    
                    doc.SetActiveTag(tag, mode=c4d.SELECTION_ADD)               
                    
            op = op.GetNext()
            
        c4d.EventAdd()
            
    def bakeIt():
        
        c4d.CallCommand(465001542, 465001542) # Timeline (F-Curves)...
        c4d.CallCommand(465001191) # Dope Sheet
        
        
        if c4d.IsCommandChecked(465001037):
            pass
        else:
            c4d.CallCommand(465001037, 465001037) # Automatic-Mode
        
        if c4d.IsCommandChecked(465001052):
            pass
        else:
            c4d.CallCommand(465001052, 465001052) # Link View to Object Manager
            
        if c4d.IsCommandChecked(465001132):
            pass 
        else:
            c4d.CallCommand(465001132, 465001132) # Link TL/OM Selection
        
        if c4d.IsCommandChecked(465001314):
            pass 
        else:
            c4d.CallCommand(465001314, 465001314) # onedirectional Selection Link
            
        c4d.CallCommand(465001056, 465001056) # Make everything visible
        
        c4d.CallCommand(465001055, 465001055) # Hide deselected
        
        gui.MessageDialog('Make sure only "Bake Expressions" and "Animated Parameters" is checked in the next window.')
            
        c4d.CallCommand(465001219, 465001219) # Bake Objects 
        
        c4d.EventAdd()
    
    
    if __name__=='__main__':
        prepareLayers(doc.GetLayerObjectRoot())
        recurse_hierarchy(doc.GetFirstObject())
        bakeIt()
        recurse_hierarchy(doc.GetFirstObject())

    prepareLayers() makes sure all tags are available for the following operations.

    recurse_hirarchy() selects all the posemorph tags.

    bakeIt() prepares the timeline window so I can call the bake command and it's only applied to the posemorph tags.
    recurse_hirarchy() selects all the posemorph tags again so I see their tracks in the timeline. That's just checking if it worked.

     

    As I said before I wasn't able to write my own bake function and therefore most of the script is preparing the setup to use the built in bake command at the end.

    I think it's working for me while it will probably make you cry if you're a programming pro ;) So for learning purposes feel free to comment what I did here

    Share this post


    Link to post

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Reply to this topic...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    Sign in to follow this  

    • Recently Browsing   0 members

      No registered users viewing this page.

    ×
    ×
    • Create New...

    FORUMS INFO:

    Dear members, we are aware of few more bugs that are still present withing the theme.We just wanted to let you know that we are working to fix them as soon as possible.
     

    NEW MEMBERS:

    Please be aware that we are manually approving all new registrations, due to spam prevention. Please be patient in case you cannot login right away, we will approve you within 12h or less if we decide you are not potential spammer. 

     

    Thanks for understanding! :cowboypistol: