Entlast doesn't select the last entity

Entlast doesn't select the last entity

3wood
Advisor Advisor
1,714 Views
7 Replies
Message 1 of 8

Entlast doesn't select the last entity

3wood
Advisor
Advisor

I drew a line in Model Space first.

Then I switch to Paper Space and drew a circle in Paper Space.

I saved and closed the drawing.

When I reopened the drawing and used (entlast) to find the circle, it actually gave me the line instead. 

How can I use (entlast) find the correct entity?

I attached an example drawing here. Can anyone help me on this issue? Thank you very much.

0 Likes
Accepted solutions (4)
1,715 Views
7 Replies
Replies (7)
Message 2 of 8

Moshe-A
Mentor
Mentor
Accepted solution

@3wood ,

 

Yes your are right...it looks like, when you open a dwg\database (entlast) return the last entity from model space so to answer your question i would step through entities in current layout, this of course if you know which layout you after 😀

 

Moshe

 

 

 

 

Message 3 of 8

cadffm
Consultant
Consultant
Accepted solution

Yes, build your own,

or if you would search about this "issue", you will find ready written codes, also in c++/Arx

 

Sebastian

Message 4 of 8

pbejse
Mentor
Mentor
Accepted solution

 

(Defun whatTheFork (/ ss)
  (setq ss (ssget "X" '((0 . "~VIEWPORT"))))
  (princ (strcat "\nSSGET 0 Index: "
		 (cdr (assoc 0 (entget (ssname ss 0))))
	 )
  )
  (princ
    (strcat "\nEntlast: " (cdr (assoc 0 (entget (Entlast)))))
  )
  (princ)
)

_$ (WHATTHEFORK)
SSGET 0 Index: CIRCLE
Entlast: LINE
Created a "DIMENSION" object (layout1 tab) | Closed the file | Open the file

_$ (WHATTHEFORK)
SSGET 0 Index: DIMENSION
Entlast: LINE
Created a "MTEXT" object (Mode tab) | Closed the file | Open the file
$ (WHATTHEFORK)
SSGET 0 Index: DIMENSION
Entlast: MTEXT

 Perhaps this

(setq ss (ssget "X" (list '(0 . "~VIEWPORT")(cons 410 (getvar 'ctab)))))
(princ (cdr (assoc 0 (entget (ssname ss 0)))))

I am as confused as you are @3wood   😄

 

 

 

 

Message 5 of 8

marko_ribar
Advisor
Advisor
Accepted solution

Check this topic...

 

http://www.theswamp.org/index.php?topic=53819.msg584844#msg584844 

 

HTH. M.R.

Marko Ribar, d.i.a. (graduated engineer of architecture)
Message 6 of 8

3wood
Advisor
Advisor

Thank you all for the great helps.

(entlast) returns the last entity in Model Space upon drawing opening.

But it doesn't always return the last entity in Model Space or Current Space during the drawing session .

Try following:

Draw a line in MS | Draw a circle in "Layout1" | Draw a rectangle in "Layout2" | Save and Close | Open | Click "Layout1" tab | Click "Model" tab, now (entget (entlast)) returns the circle in Layout1.

 

I think the best way to find out the last entity in the entire drawing upon opening is using @pbejse 's method, including (entlast) and (ssname (ssget "X" (list '(0 . "~VIEWPORT")(cons 410 (getvar 'ctab)))) 0) to go through Model Space and Paper Spaces and then find out the latest entity from the result.

0 Likes
Message 7 of 8

3wood
Advisor
Advisor

This is really helpful. Thank you Marko!

I guess (ssget "_L") doesn't return entities on a frozen layer. We may still need (ssget "_X") to get all entities.


@marko_ribar wrote:

Check this topic...

 

http://www.theswamp.org/index.php?topic=53819.msg584844#msg584844 

 

HTH. M.R.


 

0 Likes
Message 8 of 8

marko_ribar
Advisor
Advisor

Good catch, but you have "LAYTHW" command to thaw all layers and then use (c:elast)... Finally "LAYERP" command to restore layers to prvious state (frozens)...

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes