Tagging a Legend in Revit

@christopher.rossetto, I’m having problem with the script.
If i select 1 Generic Annotation and 1 Legend Component, it works fine.

But say I have 5 doors, and 5 Generic Annot for each doors for the data to be filled in, i use a window selection to select them all, the data are all mixed up.

kindly assist