Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
iref3at
366 Views, 5 Replies

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

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.

5 REPLIES 5
Message 2 of 6
komondormrex
in reply to: iref3at

hey there,

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

Message 3 of 6
Kent1Cooper
in reply to: iref3at

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
in reply to: iref3at

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

Message 5 of 6
Sea-Haven
in reply to: iref3at

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
in reply to: iref3at

@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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report