Author Topic: What is the difference between an Entity name and an ID  (Read 6372 times)

0 Members and 1 Guest are viewing this topic.

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
What is the difference between an Entity name and an ID
« on: June 04, 2007, 09:05:08 AM »
What is the difference between an Entity name and an ID?  In laymans terms please.

I am inserting a block and then setting it to a variable so I can call it up later.  Now using snippets of code from here and there I have cobbled together user selecting a polyline and an existing block and these are being set to IDs.  I tried getting the id and it crashed return nil.

Now before I start dumbing it around by trial and error to figure how to get the ID.  I want get a better understanding of two.  Do I really need the ID of Object? 

What I am using for code to get the entity name
Code: [Select]
  (SETQ NewRTBlock (ENTLAST))
what I am using for code to try and get the id of the object.
Code: [Select]
  (SETQ NewRTBlock
(vla-get-objectid
   (vlax-ename->vla-object
     (car (ENTLAST))
   )
)
  )

Quote
;;; Pass-Area-2-RmTag Lisp
;;;
;;; Purpose = Pulls "Area" Value from User Selected PolyLine
;;;         = Pulls Attribute Values from a user selection of an existing RoomTag Block
;;;         = Inserts new Room Tag Block
;;;         = Pass Data from Polyline and existing RoomTag Block to new RoomTag Block
;;;         = Deletes existing RoomTag Block
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8582
  • AKA Daniel
Re: What is the difference between an Entity name and an ID
« Reply #1 on: June 04, 2007, 09:46:05 AM »
An ObjectID is a pointer to an entity. An Entity name (as in ads_name) is a Long[2] that contains a pointer to an entity and a pointer to the space that it exists.
What you see in lisp <Entity name: 7efa5170> is basically a hexed ObjectID.

So you already got the ObjectID by calling entlast

Also you should look at storing the Object Handle instead of the ObjectID for recalling entities :added
« Last Edit: June 04, 2007, 09:55:29 AM by Danielm103 »

LE

  • Guest
Re: What is the difference between an Entity name and an ID
« Reply #2 on: June 04, 2007, 10:05:29 AM »
Code: [Select]
  (SETQ NewRTBlock
(vla-get-objectid
   (vlax-ename->vla-object
     (car (ENTLAST)) <<<<==== no no just use the (entlast)
   )
)
  )

per vlisp help...

An object ID and a unique handle are both ways of referencing an object.
In general, use a handle unless you plan to work with certain ObjectARX functions that require an object ID

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: What is the difference between an Entity name and an ID
« Reply #3 on: June 04, 2007, 10:19:47 AM »
per vlisp help...

This is issue becuase the search feature in my 08 vlisp help is blank.

An object ID and a unique handle are both ways of referencing an object.
Thanks guys

In general, use a handle unless you plan to work with certain ObjectARX functions that require an object ID
Object Handles huh
is this third way of naming an object? 

I deleted the "car" on the first try and it work.  My gut was telling me that was not needed.  Don't know why.  :-P
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

LE

  • Guest
Re: What is the difference between an Entity name and an ID
« Reply #4 on: June 04, 2007, 10:31:39 AM »
per vlisp help...

This is issue becuase the search feature in my 08 vlisp help is blank.

An object ID and a unique handle are both ways of referencing an object.
Thanks guys

In general, use a handle unless you plan to work with certain ObjectARX functions that require an object ID
Object Handles huh
is this third way of naming an object? 

Do not get confused, in the functions description on the vlisp help, you will find more information (sometimes)

That quote is referring to HANDLE only.

do this if you can:

open the visual lisp editor, and in the visual lisp console type: vla-get-objectid then highlight that function and click in the apropos button, then select again the vla-get-objectid from that list and click on the ? mark button, and it will open the help for that function if available, then at the bottom, read the remarks...

HTH

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: What is the difference between an Entity name and an ID
« Reply #5 on: June 04, 2007, 11:04:14 AM »
Do not get confused, in the functions description on the vlisp help, you will find more information (sometimes)
too late I have been affected with that disease years ago.  :-)

That quote is referring to HANDLE only.

do this if you can:

open the visual lisp editor, and in the visual lisp console type: vla-get-objectid then highlight that function and click in the apropos button, then select again the vla-get-objectid from that list and click on the ? mark button, and it will open the help for that function if available, then at the bottom, read the remarks...

HTH
Hey learn something new.  I am only using a tenth of the visual lisp editor's capicity.  :|

As for handles vs object id; and which one to use, that I am unsure of.
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

deegeecees

  • Guest
Re: What is the difference between an Entity name and an ID
« Reply #6 on: June 04, 2007, 12:13:46 PM »
Since your Developer Help is on the fritz, I thought this might help:

Quote
The handent function retrieves the name of an entity with a specific handle. As with entity names, handles are unique within a drawing. However, an entity's handle is constant throughout its life. AutoLISP applications that manipulate a specific database can use handent to obtain the current name of an entity they must use. You can use the DDMODIFY command to get the handle of a selected object.

The following code fragment uses handent to obtain and display an entity name.

(if  (not (setq e1  (handent "5a2")))
  (princ "\nNo entity with that handle exists. ")
  (princ e1)
)
In one particular editing session, this code fragment might display the following:

<Entity name: 60004722>

In another editing session with the same drawing, the fragment might display an entirely different number. But in both cases the code would be accessing the same entity.

The handent function has an additional use. Entities deleted from the database (with entdel, described in the following section) are not purged until the current drawing ends. This means that handent can recover the names of deleted entities, which can then be restored to the drawing by a second call to entdel.

Note  Handles are provided for block definitions, including subentities.

Entities in drawings that are cross-referenced by way of XREF Attach are not actually part of the current drawing; their handles are unchanged but cannot be accessed by handent. However, when drawings are combined by means of INSERT, INSERT *, XREF Bind (XBIND), or partial DXFIN, the handles of entities in the incoming drawing are lost, and incoming entities are assigned new handle values to ensure each handle in the current drawing remains unique.