entlast (AutoLISP)

Returns the name of the last nondeleted main object (entity) in the drawing

Supported Platforms: Windows and Mac OS

Signature

(entlast)
No arguments.

Return Values

Type: Ename (entity name)

An entity name; otherwise nil, if there are no entities in the current drawing.

Remarks

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.

Examples

Set variable e1 to the name of the last entity added to the drawing:

(setq e1 (entlast))
<Entity name: 2c90538>

If your application requires the name of the last nondeleted entity (main entity or subentity), define a function such as the following and call it instead of entlast.

(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