Element.SetName not working as expected

If you want to clean your script up visually, just hit CTRL + L.
It may not look amazing, but it will certainly be easier to follow than what it looks like now.

Can you do that and repost a screenshot?

Not sure why you are mapping so many things. I think it is probably easiert to just boolean mask your way to a filtered list. I would have done it like this:

I couldn’t open your script. It told me it was corrupted.
image

Other than that, I think you may generally run into issues trying to change the names of graphicstyles in Revit. Apparently it isn’t supported?