I didnt understand what you did in your code but this makes the Comment parameter of the window show North, East, South or West accordingly to the Wall:
It could be a visual glitch from revit that it is changed but Revit doesnt show it. I have the window schedule here in front of me and it shows all the windows with their correct Comments: