It does work for locked doors, as well as closed floodgates. Good find, slothen.
Edit: See my earlier post in this thread for details. There is a caveat.
Well, I'm a little surprised. Like I said, I did a lot of BD testing in v31, but I suppose it could have changed, or I could have been mistaken, maybe over-generalized. In any case, first I verified your results with a couple of captured trolls, then I set-up an experiment using clowns. (Clowns are sort of the worst-case BD. I believe they use a different pathing algorithm than normal so that their flyers can get to you.)
Anyhow, probably the easiest way to demonstrate my experiment is with the following picture:
Clowns enter from the left.
First test, locked door, available open space for building destruction. Clowns did fly up and occupy this space (as well as the ramp space). I gave them a season to destroy the door. After a season, I unlocked the door. Once unlocked, the clowns destroyed the door very quickly.
Second test, locked door, available floor for building destruction, but a change in z-level inbetween the building and the space they'll try to destroy it from. After destroying the first door, the clowns didn't even move onto this door. I briefly unlocked the door, and the clowns approached, and I relocked the door, upon which the clowns lost interest again. Having seen the speed with which they destroyed the first door, I didn't give them a full season to see if they'd destroy this door, and instead opened it for them after a month had passed. After unlocking it, once again, the clowns destroyed it very quickly.
Third test, locked door, available floor behind the door. Accidentally left unlocked, clowns destroyed it, previous tests suggest they would have ignored it had I locked it.
Fourth test, hatch, no available floor. Clowns ignored the hatch and moved on (to my clown trap, where they were summarily destroyed).
Edit: Anther interesting observation-- these small ramps really confused the flying clowns. They tended to get stuck in the open space above the ramp, and then stop pathing to my clown trap.