iterating on multiple Tmgselection tags



  • When I use this Script:

    MoSelectionTag =  mo.GeGetMoDataSelection(op)
    Count = MoSelectionTag.GetCount()
    

    I can get the moSelection Tag (Tmgselection) Count. So far so good.
    But if I have more than 1 moSelection Tags, I need to iterate all tags, find the Tmgselection and get the Count for each one.
    Why doesn't this code work? How do I iterate through the tags and get the count of each Tmgselection?
    This code is in a Python Tag.

    import c4d
    from c4d.modules import mograph as mo
    
    def main():
        Cloner =  op.GetObject()
        md = mo.GeGetMoData(Cloner)
        AllTags = Cloner.GetTags()
        
        for Tag in AllTags:
    
            if Tag.GetType() == c4d.Tmgselection:
                print Tag
                print Tag.GetCount()
    

    it throws an Error:
    'c4d.BaseTag' object has no attribute 'GetCount'

    Cheers



  • Replying to my own question. We need to define it using

    mo.GeGetMoDataSelection(Tag)
    

    Code that works.

    import c4d
    from c4d.modules import mograph as mo
    
    def main():
        Cloner =  op.GetObject()
        md = mo.GeGetMoData(Cloner)
        AllTags = Cloner.GetTags()
        
        for Tag in AllTags:
    
            if Tag.GetType() == c4d.Tmgselection:
                print Tag
                SelTag = mo.GeGetMoDataSelection(Tag) #This is the new line
                print SelTag.GetCount()
    


  • Replying to my own question. We need to define it using

    mo.GeGetMoDataSelection(Tag)
    

    Code that works.

    import c4d
    from c4d.modules import mograph as mo
    
    def main():
        Cloner =  op.GetObject()
        md = mo.GeGetMoData(Cloner)
        AllTags = Cloner.GetTags()
        
        for Tag in AllTags:
    
            if Tag.GetType() == c4d.Tmgselection:
                print Tag
                SelTag = mo.GeGetMoDataSelection(Tag) #This is the new line
                print SelTag.GetCount()
    

Log in to reply