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.
Solved! Go to Solution.
Solved by Kent1Cooper. Go to Solution.
Solved by komondormrex. Go to Solution.
hey there,
mark the last object, place multiple objects, select placed objects after marked one till db end.
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.
Thank you @Kent1Cooper for the demonstration, it worked perfectly.
and @komondormrex for bringing it up 🙂
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.
@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.