Why do you call a building to attention when an officer is leaving?

It is military protocol to call a room or building to attention when a senior officer enters or leaves. That is, if the highest ranking officer in the room is a 2nd Lieutenant, and a Captain enters, the LT would call the room to attention. If, for instance, the building holds the offices of the commanding General, the building is called to attention when he enters in the morning, and when he leaves at days end. Unless he give specific orders to the contrary, this will not happen again throughout the day, provided one of his superiors does not enter the building (this would never occur unannounced, and the General's Adjutant would likely be the officer to call attention when this happened).

The purpose is tradition, prespect, recognition of the chain of command.
It is military protocol to call a room or building to attention when a senior officer enters or leaves. That is, if the highest ranking officer in the room is a 2nd Lieutenant, and a Captain enters, the LT would call the room to attention. If, for instance, the building holds the offices of the commanding General, the building is called to attention when he enters in the morning, and when he leaves at days end. Unless he give specific orders to the contrary, this will not happen again throughout the day, provided one of his superiors does not enter the building (this would never occur unannounced, and the General's Adjutant would likely be the officer to call attention when this happened).

The purpose is tradition, prespect, recognition of the chain of command.