Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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

    Tag out of sync problem

    Scheduled Pinned Locked Moved PYTHON Development
    4 Posts 0 Posters 513 Views
    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.
    • H Offline
      Helper
      last edited by

      On 25/04/2017 at 03:02, xxxxxxxx wrote:

      Hi 🙂

      I am sorry for asking something this simple, haven't done much scripting but I have a really simple script, that creates a NormalTag on the selected objects. It's working fine on primitives but not on real geometry.

      It crashes C4D if I execute the script on a 3D mesh with the error: Object "ObjectName" - Tag 5711 not in sync. Any hints on how to fix it and what I am doing wrong?

      Thank you in advance!

      def main() :
          doc.StartUndo()
          
          objs = doc.GetActiveObjects(1)
          
          if not objs:
              gui.MessageDialog('No objects selected.')
              return
          
          for i in objs:
              
              tag = i.MakeTag(c4d.Tnormal)
              doc.AddUndo(c4d.UNDOTYPE_NEW, tag)
              
          c4d.EventAdd()
          
          doc.EndUndo()
          
      if __name__=='__main__':
          main()
      
      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 25/04/2017 at 03:37, xxxxxxxx wrote:

        normalTag are special variable tag since they need parameter for init (basicly the number of polygons)

        import c4d
          
        def main() :
            doc.StartUndo()
            objs = doc.GetActiveObjects(1)
            
            if not objs:
                c4d.gui.MessageDialog('No objects selected.')
                return
            
            for obj in objs:
                normalTag = op.GetTag(c4d.Tnormal)
                if normalTag:
                    print 'tag already exist'
                    continue
                
                #if there is no tag initg:
                poly_cout = obj.GetPolygonCount()
                normalTag = c4d.NormalTag(poly_cout)
                
                #Assign
                doc.AddUndo(c4d.UNDOTYPE_NEW, normalTag)
                obj.InsertTag(normalTag)
                
                
            c4d.EventAdd()
            
            doc.EndUndo()
            
        if __name__=='__main__':
            main()
          
        
        

        For manipulate data I suggest you to read the c++ sdk wich is way mroe relevant than the python one on this topic.
        https://developers.maxon.net/docs/cpp/2023_2/page_manual_normaltag.html

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 25/04/2017 at 04:11, xxxxxxxx wrote:

          Thanks for the super fast reply and the help!
          Will definitly read up on this 🙂

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            On 26/04/2017 at 10:06, xxxxxxxx wrote:

            Hi Dimitri,

            welcome to the Plugin Café forums 🙂

            Glad to see, your question is already answered. Again, thanks, gr4ph0s!

            Since you are new here, I was just chiming in to provide the link to our Development Blog, as I did in the other thread. So nobody feels left behind...

            1 Reply Last reply Reply Quote 0
            • First post
              Last post