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

    iterating on multiple Tmgselection tags

    Cinema 4D SDK
    1
    2
    367
    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.
    • N
      noseman
      last edited by noseman

      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

      1 Reply Last reply Reply Quote 0
      • N
        noseman
        last edited by

        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()
        
        1 Reply Last reply Reply Quote 1
        • First post
          Last post