one small correction to the code posted by Glenn: after calling createVerticesArray on line 14, add the line:
trans_h.pop
otherwise, if there are multiple sub-components in the entities collection, you will take into account the transformation of any entity that came before.
Otherwise, great code, very useful.
Thanks!
--
Karen