Returns the name of the last nondeleted main object (entity) in the drawing
The entlast function is frequently used to obtain the name of a new entity that has just been added with the command function. To be selected, the entity need not be on the screen or on a thawed layer.
(setq e1 (entlast)) <Entity name: 2c90538>
(defun lastent (/ a b) (if (setq a (entlast)) Gets last main entity (while (setq b (entnext a)) If subentities follow, loopsuntil there are no more (setq a b) subentities ) ) a Returns last main entity ) or subentity