Does object has entity number from born?.

Does object has entity number from born?.

Anonymous
Not applicable
1,368 Views
5 Replies
Message 1 of 6

Does object has entity number from born?.

Anonymous
Not applicable

Hello, community.

 

I want to know that object that user creates something ( line, circle, etc.) has their creating number.

Adding more example, When who makes Some products, they made it with counting on their products from a factory, First phone, Second phone.

Therefore, I think that objects can have their numbering in CAD.

That is reason why,

There is a ptManager lisp that is made by lee mac.

When I use it, A lot of points of  X,Y,Z coordinate transfer to CSV file.

The more important things, The points list in CSV file will be arrangement according to their born order.

First creating point sets to the first column in CSV file, Second creating point places to the second column in CSV file.

 

Thanks.

0 Likes
Accepted solutions (1)
1,369 Views
5 Replies
Replies (5)
Message 2 of 6

TheCADnoob
Mentor
Mentor

I think you may have partially answered your own question. 

 

If a lisp like those created by lee mac can sort by an entity ID then it was given an entity ID when it was put in the drawing database. 

 

to get much more specific you may need to ask the question to those who access the IDs more frequently. The following link is to the forum which uses and discuss LISP and other elements which access lower level drawing information. 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/bd-p/130

 

Also this is an interesting article discussing accessing elements by their ID: http://through-the-interface.typepad.com/through_the_interface/2007/02/getting_access_.html

 

 

If you want to know the explicit process you may have to reach out to a creator group and not a user group.

 

CADnoob

EESignature

0 Likes
Message 3 of 6

Kent1Cooper
Consultant
Consultant

An object's entity name [the (cdr (assoc -1 entitydatalist)) value] can sometimes change when you close a drawing and reopen it, and possibly at other times.  But its handle [the (cdr (assoc 5 entitydatalist)) value] is permanent.  I believe handle numbers always increase as objects are added, so sorting by them should always get things in drawn order.  But handles are hexadecimal [base-16] numbers represented by text strings.  To sort by them would require a hexadecimal-to-integer converter -- do some Searching [possibly here, certainly in the Customization Forum] and you'll find some.

Kent Cooper, AIA
Message 4 of 6

john.uhden
Mentor
Mentor

Following what @Kent1Cooper advised about using handles, and how they are hexadecimal, here are three functions contributed by @dbroad in March of 2003...

 

(defun HexDigit (x)
  (if (< x 10)
    (itoa x)
    (chr (+ 55 x))
  )
)

;;Conversion from decimal to hexadecimal
(defun ToHex (n / l)
  (while (< 15 n)
    (setq l (cons (fix (rem n 16)) l)
          n (/ (- n (car l)) 16))
  )
  (setq l (cons (fix n) l))
  (apply 'strcat (mapcar 'HexDigit l))
)

;;Conversion from hexadecimal to decimal
(defun FromHex (str  / sum)
  (setq sum 0)
  (foreach n (vl-string->list (strcase str))
    (setq n (if (< n 65) (- n 48)(- n 55)))
    (setq sum (+ n (* sum 16.0)))
  )
)

John F. Uhden

Message 5 of 6

Anonymous
Not applicable

Thank your answer!.

I tested about hexadecimal value to find object own number.

I created object sequentially, and Then I convert it to decimal.

I found that increasing value is not constant.

Is there any pattern for increasing value??.

0 Likes
Message 6 of 6

_gile
Consultant
Consultant
Accepted solution

Hi,

 

Any Autocad object (graphical entities as well as non-graphical objects -layers,layouts, etc.) have a handle as persistant identifier in the drawing.

 

Example

You draw a circle, AutoCAD creates a new handle for this entity: "421"

Then you draw a 3d polyline with 3 vertices AutoCAD creates a new handle for this entity: "422"

Finally you draw another circle, AutoCAD creates a new handle for this entity: "427"

 

Why "427"? Because 3d polylines are complex entities which contain sub entities (vertices). so when you drew the 3d polyline, AutoCAD gave the Polyline itself the handle "422" but also a SEQEND object which handle is "423" and three VERTEX objects "424", "425" and "426" handles.

 

If you erase the 3d polyline, the second circle handle will always remain "427".

 

Imagine you insert an external DWG as block, AutoCAD will create a handle for the newly insterted block reference after having assigned handles to the block definition, to all the entities within this definition and all the newly added non-graphical objects brought with these entities.

 

To conclude, only the order of the graphical entities is reliable. Comparing two handles you can only say which have been created after the other but not how many have been created between them and remain in the drawing.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub