How can I select the element/elements created during the very last transaction.

How can I select the element/elements created during the very last transaction.

iref3at
Contributor Contributor
808 Views
5 Replies
Message 1 of 6

How can I select the element/elements created during the very last transaction.

iref3at
Contributor
Contributor

Hello,

I am using a LISP command that allows the user to place an object or more (multiple) to a dwg, after that I should select all inserted objects and do one more operation on all of them.

 

I tried 

_SELECT (entlast)

 

and 

 

_SELECT (ssget "L")

 

Both of them select the last object only, and this is logically wrong when the user has placed many. although elements are considered one transaction and can be undo-ed in a single undo action.

 

Any way of retrieving a list for example or a selection set containing all of them?

 

Thanks in advance.

0 Likes
Accepted solutions (2)
809 Views
5 Replies
Replies (5)
Message 2 of 6

komondormrex
Mentor
Mentor
Accepted solution

hey there,

mark the last object, place multiple objects, select placed objects after marked one till db end.

Message 3 of 6

Kent1Cooper
Consultant
Consultant
Accepted solution

You do need to know ahead of time that you want to do this.  You can, as @komondormrex suggested, put the last already-existing object, i.e. (entlast) into a variable as a basepoint beforehand, and when done drawing new things, as long as there continues to be an (entnext) object after that and after each other, add it to a selection set or a list of entity names.

 

Or, depending on how things are being drawn, to the extent that it's an automated procedure, you could have each new thing added to the selection set or list of entity names as it's drawn, instead of waiting to the end and then going back to find them all.  If that can work, it would not require the saving ahead of time of the basepoint last object.

Kent Cooper, AIA
Message 4 of 6

iref3at
Contributor
Contributor

Thank you @Kent1Cooper for the demonstration, it worked perfectly.
and @komondormrex for bringing it up 🙂 

0 Likes
Message 5 of 6

Sea-Haven
Mentor
Mentor

Like the others as you make an object, note singular use (ssadd (entlast) ss) so you end up with a selection set ss. Must do (setq ss (ssadd)) 1st as this makes an empty selection set, then can add to it.

Message 6 of 6

john.uhden
Mentor
Mentor

@iref3at ,

One has to be careful with entlast.

It will always return the last primary entity, but if it is a block with attributes or a polyline with vertices, then there are additional subsequent entities not returned.  IOW entlast may not return the very last entity created.

This can be a PITA if you are expecting (entnext (entlast)) to return the next primary entity.

Ergo, I use this:

   ;;----------------------------------------
   ;; Function to get absolutely last entity:
   ;;
   (defun @entlast ( / elast e)
     (setq elast (entlast))
     (while (setq e (entnext elast))
       (setq elast e)
     )
     elast
   )

 

John F. Uhden

0 Likes