Tag out of sync problem

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()

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/Cinema4DCPPSDK/html/page_manual_normaltag.html

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

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

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...