A very good question and one that could be easily justified either way actually.
If you look at Kevin Tewart's Damage Step chart (the very first post on the judge's list) you'd find according to it that the effects of monster who's effect activates "at the end of the damage step" is carried out after the portion of the damage step where monsters are sent to the graveyard....so according to that Ancient Gear Engineer's effect wouldn't work if destroyed in the damage step.....
HOWEVER...
According to the rulings on Legendary Jujitsu Master....
If "Legendary Jujitsu Master" is destroyed, removed from play, or flipped face-down by the effect of the monster he battles with, "Legendary Jujitsu Master"'s effect is still applied and the monster is returned to the top of the Deck.
Now when you compare that with the text of Ancient Gear Engineer...
Text :
Negate the effect of any Trap Card that targets this card, and destroy that Trap Card. If this card attacks, your opponent cannot activate any Spell or Trap Cards until the end of the Damage Step. When this card attacks, destroy 1 Spell or Trap Card on your opponent's side of the field at the end of the Damage Step.
You can see that both cards trigger before the end of the damage step. Ledgendary Jujitsu Master when it's attacked in def. postion and Ancient Gear Engineer when it attacks.
Due to their similar text I'd rule (at this point not having a written ruling on it) that Ancient Gear Engineer would destroy COTH even though Ancient Gear Engineer is considered destroyed itself (and technically, according to the damage step chart, already in the graveyard)
Does it make a whole lot of sense? Well, not to me, not right now, I'm going to do some further study on the subject and I'll get back with you. Thank you for bringing it up....going on these little "hunts" for ruling information and mechanics is how I learn the most!