Tagging Windows, Sorted by Parameter

This is my first script that I have built by myself and I’m running into an issue. My assumption is that I’m feeding a list into an input that wants elements, but when I trace back to when I first get my elements it seems like they should be carried through.

I’m also assuming there is probably a much more efficient way of writing this script.

Could I get some help pinpointing what my issue is? The script was quite large so I couldn’t take a good screenshot. Attached is the file.

Thanks
Tag Windows_Offset.dyn (123.4 KB)

To provide some context because I saw a comment that asked about the auto-tagging for Revit.

There have a been a few times when we end up placing dim lines after we have placed the window tags. When you do that the dim line goes over the tag. I do not see any way of adjusting the order of these items. So I end up needing to delete the tags and retagging the windows. This ultimately is not hard to do, especially since I have shortcuts programmed to my keyboard. Regardless, it requires a handful of clicks to perform this and if I can automate that process I want do so.

I got this script working, but it would offset the tag the same for all the windows. So tags were correct on one side, but then not correct on the other side. So that is where the sort by parameter aspect of the script came into being.

I was finally able to figure it out, and like I thought the solution was simpler than I was trying to make it.

Below is the updated file.

My plan is to incorporate a user interface so I can have it on my toolbar.

Tag Windows_Offset.dyn (436.3 KB)