entnext
(entnext [entity])
With no argument, the first entity of the drawing; with an entity, the next one (or nil at the end). It goes through model space and then the layouts; after an INSERT with attributes come its ATTRIBs and the SEQEND, as in AutoCAD.
(setq e (entnext)) (while e (setq e (entnext e)))