Select Last Created Object Macro

Select Last Created Object Macro

jpskipper97EKZRZ
Participant Participant
1,865 Views
6 Replies
Message 1 of 7

Select Last Created Object Macro

jpskipper97EKZRZ
Participant
Participant

Hello,

 

I'm looking for a macro that would select the last created object. The intent is that when you use this commanded instead of having to select the object that was just created, it would automatically select it. I am also open to inserting the function into the lisp file for this command. 

 

Thank you!

0 Likes
Accepted solutions (1)
1,866 Views
6 Replies
Replies (6)
Message 2 of 7

murray-clack
Advisor
Advisor

There's a command called PSELECT which allows you to select either the Last object created, or, the Previous selection set (i.e. the last group of objects that were selected)

 

I created a LSP routine that automatically loads with the following code:


;;;SELECT-OBJECT-GRIPS.lsp written by Murray Clack, April 4, 2005
;;;Tested on AutoCAD 2005
;;;This routine allows you to select either the Previous selection set
;;;or Last object created with its grips highlighted.

(prompt "\nSELECT-OBJECT-GRIPS.lsp loaded ")
(prompt "\nEnter PSP to select Previous selection set with grips highlighted...")
(prompt "\n...or PSL to select Last object created with grips highlighted ")

(defun c:PSP ()
(command ".pselect" "p" "")
(princ)
)

(defun c:PSL ()
(command ".pselect" "l" "")
(princ)
)

0 Likes
Message 3 of 7

jpskipper97EKZRZ
Participant
Participant

Thank you! Although I'm having some trouble achieving my desired product (very little lisp experience). The end goal is this command automatically selecting the last created object and opening the dialogue window without the need to select the object manually. Would you be able to help figure out how to make this happen?

0 Likes
Message 4 of 7

ВeekeeCZ
Consultant
Consultant

It cannot be done without rewriting the fiber lisp. Who the author is, are we allowed to do that?

0 Likes
Message 5 of 7

jpskipper97EKZRZ
Participant
Participant

I'm perfectly fine with it being re-written, just trying to optimize it so its as easy as possible.

0 Likes
Message 6 of 7

ВeekeeCZ
Consultant
Consultant

Replace this line

	(setq e (entget (car (entsel)) '("AFRALISP")))

with this one:

	(setq e (entget (if (ssget "_I") (ssname (ssget "_I") 0) (car (entsel))) '("AFRALISP")))

The macro for selection the last item... use simply:

(sssetfirst nil (ssget "_L"))

 

Message 7 of 7

cadffm
Consultant
Consultant
Accepted solution

@jpskipper97EKZRZ 

Really the (one) LAST Object?

 

1. Change the commandname, because you edit the program, "fiberl" for example - fiber-last

   change c:fiber to c:fiberl

 

2. The last Objekt

    Change (car (entsel)) to (entlast)

 

@murray-clack 

Pselect is a special thing and not always available! And for LT-readers: Not available in LT versions.

(perhaps you didn't notice it because your properties palette is always loaded)

If you can use Lisp -you do- use (sssetfirst nil (ssget "_p"))

 

 

 

Sebastian

0 Likes