import c4d
from c4d import gui

def GetChildren(obj):
    children = []
    children.append(obj)
    for child in obj.GetChildren():
        children.extend(GetChildren(child))
    return children

def main():
    
    
    SIGNAL = 1031805
    objs = doc.GetObjects()
    allChildren = []
    for obj in objs:
        allChildren.extend(GetChildren(obj))
    if len(allChildren)<0: return 
    doc.StartUndo()
    doc.AddUndo(c4d.UNDOTYPE_CHANGE_SMALL, doc)
    
    doc.SetActiveTag(None)
    for child in allChildren:
        tags = child.GetTags()
        for tag in tags:
            if tag.GetType() == SIGNAL:
                doc.SetActiveTag(tag,c4d.SELECTION_ADD)
        
        
        
        
        #Start Here
        
  

        
        
        #End here   
    
    doc.EndUndo()
    c4d.EventAdd()
    
    
if __name__=='__main__':
    main()
