You're most welcome qwrtz

A few points to note:
Since the value of DXF Group -1 is a pointer to the entity itself, observe that:
Is equivalent to just:
Be careful when stepping through the entities following a call to
(entlast) since, if the entity returned by
(entlast) is a complex entity (such as an attributed block or 3D polyline), the subsequent calls to
(entnext) will return the subentities which follow the parent entity (i.e. the attribute references or 3D polyline vertices respectively). For this reason, I suggested the
lastent function that I posted above, which will return the last entity in the drawing database for which a call to
(entnext) will return
nil.
The same logic applies to MP's
_SSAfter function: note that this function will attempt to add subentities to the returned selection set; since it is not possible to add the terminating
SEQEND entity to a selection set, the
ssadd function will consequently return
nil, causing the
ss variable to become
nil within the
while loop, and so the function will always return
nil if complex entities have been added to the database after the entity supplied to the function.
I should have clarified in the original post that I didn't want to write a routine that creates specific new entities. I wanted the routine to execute a normal COPY or MIRROR command (with the selection set and displacement or mirror line specified at run time), except that when it's done all the newly created entities are selected for use in the next command.
Perhaps my example was confusing since the example was creating entirely new objects, but please note that the same method may be applied to any command for which you want to obtain the set of all entities potentially created by the command, e.g.:
(defun c:lmcopy
( / cpm ent new sel
)
(if ;; If the following expression returns a non-nil value ;; (i.e. if the user makes a valid selection)
(setq sel
(ssget)) ;; Prompt the user for a selection
(setq ent
(lastent
) ;; Retrieve the last entity added to the database new
(ssadd) ;; Create an empty selection set for the new entities cpm
(getvar 'copymode
) ;; Store the value of the COPYMODE sys var ) ;; end setq
;; Set the COPYMODE sys var as appropriate
(command "_.copy" sel
"" "\\" "\\") ;; Invoke the COPY command
;; Reset the COPYMODE sys var
;; (always store/restore the original sys var value, don't assume that you know what that value should be)
(while (setq ent
(entnext ent
)) ;; While there is another entity in the database (ssadd ent new
) ;; Add it to the new selection set
;; If subentities follow this entity
;; Iterate over them until we reach the terminating SEQEND entity:
) ;; end while
) ;; end if
) ;; end while
;; Highlight the new objects
) ;; end progn
) ;; end if
;; Supress the return of the last evaluated expression
) ;; end defun
(defun lastent
( / rtn tmp
) rtn
)