Entity data without select, but I know the name

Entity data without select, but I know the name

Henrik_Lo
Collaborator Collaborator
1,399 Views
11 Replies
Message 1 of 12

Entity data without select, but I know the name

Henrik_Lo
Collaborator
Collaborator

HI

 

How can I access this entity data without select, but I know the name <Entity name: 1775e9eb1d0>, in this case it is a line. I need to reopen the drawing and read new end points coordinates.

There are more lines I this drawing too, i need looking for 2 of therm.

 

By the way, will this entity always have this name in same drawing.

 

Regards

Henrik

0 Likes
Accepted solutions (1)
1,400 Views
11 Replies
Replies (11)
Message 2 of 12

dlanorh
Advisor
Advisor

@Henrik_Lo wrote:

HI

 

How can I access this entity data without select, but I know the name <Entity name: 1775e9eb1d0>, in this case it is a line. I need to reopen the drawing and read new end points coordinates.

There are more lines I this drawing too, i need looking for 2 of therm.

 

By the way, will this entity always have this name in same drawing.

 


I'll answer the second bit first. The entity will not have the same name in the same drawing. The only thing that can be guaranteed not to change is the entity handle within that drawing.

The entity handle can be obtained by selecting an entity using

 

(princ (cdr (assoc 5 (entget (car (entsel "\nSelect Entity : "))))))

To use the handle to re-find the entity use

 

(setq ent (handent (getstring "\nEnter Entity Handle : ")))

the variable (ent) will then contain the entity you want.

 

 

I am not one of the robots you're looking for

0 Likes
Message 3 of 12

Henrik_Lo
Collaborator
Collaborator

HI

Thanks for helping me out, I will try work that way then.

Regards

Henrik

0 Likes
Message 4 of 12

dlanorh
Advisor
Advisor

you might find this useful. It asks for the handle then zooms to the extents of that entity.

 

(defun c:zh ( / a_app e_str ll ur ent)
  (vl-load-com)
  (setq a_app (vlax-get-acad-object)
        e_str (getstring "\Enter Entity Handle : ")
ent (handent e_str) );end_setq (vla-getboundingbox (vlax-ename->vla-object ent) 'll 'ur) (vla-zoomwindow a_app ll ur) );end_defun

If you want to get the start and end points of a line just replace the last two (vla...) statements with the code you want

I am not one of the robots you're looking for

0 Likes
Message 5 of 12

Henrik_Lo
Collaborator
Collaborator

HI

yes, also a very handy tool, thangs.

Regards

Henrik

0 Likes
Message 6 of 12

Kent1Cooper
Consultant
Consultant

Zooming to it, if that's what you want to do, can be simpler:

(defun C:ZH ()
  (command "_.zoom" "_object" (handent (getstring "\nHandle of object to Zoom to: ")) "")
)

 

Kent Cooper, AIA
0 Likes
Message 7 of 12

Henrik_Lo
Collaborator
Collaborator

HI

 

Iam still struggling to be able to know start and endpoints as explained, i were explained  that  i could be sure regarding the entity handle were the same. But they are also change names each time I reopen this drawing.

 

Iam use this drawing Prototyp_LISP, and need to use for prototype template, but I need to change some detailed by lisp, therefore I need to how the line names , see my enclosed prototype drawing and explain file.

 

Regards

Henrik

 

0 Likes
Message 8 of 12

devitg
Advisor
Advisor

As I can see , there are  only two block references, and such enty do not have any assoc 10 . 

If you need to know te line from the leftmost point to the more rightmost point , it have to be do with the BOUNDING BOX method  

Please see attached file 

0 Likes
Message 9 of 12

Kent1Cooper
Consultant
Consultant

Since the example drawing contains no top-level Line entities, it's impossible to get endpoints from them, but if the edges you point to in your image are what you're after, they might be extracted by digging into the ingredients of the Block definition, which is complicated.  If you save the entity handles  from the Lines you want, before defining the Block that they become a part of, presumably a routine could open the Block definition in the Block table, and step through its pieces until it finds those handles, and get the endpoints of those Lines.  But I'm not sure how entity handles are affected by something being nested inside a Block definition.  But if that's a viable approach, what it will get will be coordinates relative to the Block's insertion point, when the Block is at a scale factor of 1 and rotation of zero.  [That happens to be true in your sample drawing, but I assume it would not always be, or you wouldn't need to ask the question.]  The results would not  be in the current drawing's coordinates, so some kind of translation would be required if you want drawing coordinates of those endpoints.  It would need to account for where the insertion point is, and would get more complicated if there might be scale factors other than 1 or rotation other than zero degrees.  Is that what you are looking for?

Kent Cooper, AIA
0 Likes
Message 10 of 12

Henrik_Lo
Collaborator
Collaborator

HI

Iam after the endpoint form the 2 lines, I need to make a automatic dimension I layout space, therefore I need the exact location to be able to do that. It sound to me that it is an impossible mission with this block, if this is right, I need to find another way to find them, but how.

Regards

Henrik

0 Likes
Message 11 of 12

Kent1Cooper
Consultant
Consultant

@Kent1Cooper wrote:

....  But I'm not sure how entity handles are affected by something being nested inside a Block definition.  ....


 

Unfortunately, I find in a quick experiment that when I check the handle of a Line, then include that Line in a Block definition, and Insert that Block, getting the entity data from the nested Line with

  (entget (car (nentsel)))

reveals that it now has a different  handle.  However, when I close the drawing and re-open it, the nested Line's handle still has that same changed value.  And that's true in each occurrence of that Line nested in multiple Insertions of that Block.

 

So if, rather than save the handle of the Line before putting it into a Block definition, you can get its handle from within the Block, it should be possible to find that again later by stepping through the Block definition's pieces.  HOWEVER, I find that with multiple coinciding objects [such as your Line along the edge of a Hatch pattern], you don't seem to get any choice about which object is seen  when you pick on a location shared by more than one thing.  So I'm not sure how to get the handle of the nested Line in a reliable way.

Kent Cooper, AIA
0 Likes
Message 12 of 12

Henrik_Lo
Collaborator
Collaborator
Accepted solution

HI Kent

I must tray to be more creative then, maybe place something in this 4 points on a layer i cans witch off and maybe find them trout that.

 

Regards

Henrik

0 Likes