.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Object id

28 REPLIES 28
Reply
Message 1 of 29
danny.boy.1
1347 Views, 28 Replies

Object id

Hello

Can someone help me with this issue.

I think that object id is not constant, because after each autocad relaunching it changes.
Is there some way to find unique number or the name of the object?

Best regards
Danijel Ivankovic
28 REPLIES 28
Message 2 of 29
Anonymous
in reply to: danny.boy.1

danny.boy.1 wrote:

> Hello Can someone help me with this issue. I think that object id is
> not constant, because after each autocad relaunching it changes. Is
> there some way to find unique number or the name of the object?

ObjectIDs and handles can change. When one drawing is inserted into
another these often change. The only way I have seen to maintain a
static ID is to attach a *unique* value as XDATA.

Terry
Message 3 of 29
danny.boy.1
in reply to: danny.boy.1

Thank you terry,

do you have some example or something what can help me
with XDATA.

Best regards
Danijel Ivankovic
Message 4 of 29
Anonymous
in reply to: danny.boy.1


ObjectId is only kept within the AutoCAD
session in whcih drawing is opened (i.e. drawing database is read into Acad
session from dwg file), while Entity's handle persists across AutoCAD sessions,
that is, an entity's handle remains unchanged when a drawing is opened
again.


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Hello
Can someone help me with this issue. I think that object id is not constant,
because after each autocad relaunching it changes. Is there some way to find
unique number or the name of the object? Best regards Danijel
Ivankovic
Message 5 of 29
Anonymous
in reply to: danny.boy.1

danny.boy.1 wrote:

> Thank you terry, do you have some example or something what can help
> me with XDATA.

There are examples of xdata storage/retrieval on this group you can
search for and you can use System.Guid.NewGuid or another method to
generate the key.

Terry
Message 6 of 29
Anonymous
in reply to: danny.boy.1

Terry gave you some bad info.

Handles are permanent. ObjectIds are not.

You can use handles to permanently identify an entity in a specific drawing.

A copy of an entity, within the same drawing or another drawing, is NOT the
same entity, so anything that Terry thinks he's attaching to serve as a
'permanent' identifier is nothing of the sort, since it will be replicated
in every copy.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");


wrote in message news:6189466@discussion.autodesk.com...
Thank you terry, do you have some example or something what can help me with
XDATA. Best regards Danijel Ivankovic
Message 7 of 29
Anonymous
in reply to: danny.boy.1

Tony Tanzillo wrote:

> Terry gave you some bad info.

No, Terry have him some good info.

> Handles are permanent.

Sorry, your wrong! If you insert a drawing into another drawing, the
handles WILL CHANGE.

Terry
Message 8 of 29
Anonymous
in reply to: danny.boy.1

Inserting one drawing into another is a form of *copying* the objects in the
source drawing.

.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");


"Terry W. Dotson" wrote in message
news:6189840@discussion.autodesk.com...
Tony Tanzillo wrote:

> Terry gave you some bad info.

No, Terry have him some good info.

> Handles are permanent.

Sorry, your wrong! If you insert a drawing into another drawing, the
handles WILL CHANGE.

Terry Edited by: Discussion_Admin on May 29, 2009 10:14 AM
Message 9 of 29
Anonymous
in reply to: danny.boy.1

Sorry you can't admit your wrong. Your statement:

"Handles are permanent "

Is incorrect.

Terry Edited by: Discussion_Admin on May 29, 2009 10:15 AM
Message 10 of 29
Anonymous
in reply to: danny.boy.1

Handles are permanent. Edited by: Discussion_Admin on May 29, 2009 10:16 AM
Message 11 of 29
dgorsman
in reply to: danny.boy.1

Something a little more professional...



For casual purposes, handles should be enough to identify objects. If your users use the "wblock/copy-paste to new drawing" method of fixing problem drawings, then any handles you have stored will be invalid - as noted, this is considered creating a copy of the object. Its also important to consider if you are tracking unique items in an external storage system such as a database, as the drawing contents can change, undo-commands can be issued, which can cause a difference between the data storage value and the actual object handle. XDATA\XRECORDS allow for a separate system of providing unique identification based on your own needs. Naturally it requires a little more up-front planning but can be worth looking into.
----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


Message 12 of 29
danny.boy.1
in reply to: danny.boy.1

Thanks a lot everyone.

All posts have been useful for me.

XDATA are very interesant, and I will use it.

Best regards
Danijel Ivankovic
Message 13 of 29
dgorsman
in reply to: danny.boy.1

You are welcome.
----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


Message 14 of 29
LAmbrosius
in reply to: danny.boy.1

An objects handle is consistent from drawing session to drawing session while an object id can and usually is different when you close and repoen a drawing. You can think of an object's handle much like a unique index in a SQL or MS Access database, the number is never used again with in that same drawing.

If you copy objects from one drawing to another, the copied objects are assigned new handles and object ids. As Terry mentioned, if you want each object to have a unique id, using a GUID number is the best way and attaching it via XDATA to the object. XDATA is also mainatined when copying objects between drawings, but you will need to monitor when an object is created though to update the XDATA when a copy of an object is created.

Good luck.
Message 15 of 29
Anonymous
in reply to: danny.boy.1

Most of the replies you got are from people who
don't seem to understand the problem at all or the fact that using a GUID or
other 'unique' string attached to an object's XData doesn't work, because
when you copy an object within the same drawing, the ummmm 'unique'
identifier is copied along with it, and hence, it is duplicated and
therefore no longer unique.

In order to implement your own 'unique' identifier that is guaranteed to be
unique within a drawing (or across several drawings), you must handle deep
clone events on the Database, and in the handler of the event, you must
*change* the unique identifier in the cloned object.

However, even with that, the approach being suggested still does not work,
because:

1. COPYCLIP + PASTECLIP has no deep clone context, even though the
result is identical to using the COPY command.

2. If the drawing is edited without your application loaded, then the
simple act of copying an object with one of the so-called 'unique'
identifiers results in two or more objects with the same 'unique' identifer,
and when your app does get control back again, it has no way of knowing
which of the multiple objects with the same 'unique' identifier is the
original, and which are the copies of it.

3. It takes much longer to locate an object given the 'unique'
identifier, as opposed to using handles.



--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");


wrote in message news:6190507@discussion.autodesk.com...
Thanks a lot everyone. All posts have been useful for me. XDATA are very
interesant, and I will use it. Best regards Danijel Ivankovic Edited by: Discussion_Admin on May 29, 2009 10:23 AM
Message 16 of 29
Anonymous
in reply to: danny.boy.1

With a XData tag you can find the object even after the object moves
from drawing to drawing, which happens in the real world. Those
transfers may take place on systems you have no code running in, in
other words no control. If multiples of the XData tag exist (because of
copies), that in combination with the smallest handle you are likely to
be able to determine the original.

If you don't use my tag approach and rely exclusively on the handle, you
are either unlikely to find the object at all, or worst, get the wrong
object.

Terry Edited by: Discussion_Admin on May 29, 2009 10:24 AM
Message 17 of 29
Anonymous
in reply to: danny.boy.1

Tony Tanzillo wrote:

> 3. It takes much longer to locate an object given the 'unique'
> identifier, as opposed to using handles.

The difference is very small as AutoCAD is quite *fast* at returning
objects that match an AppID.

Terry
Message 18 of 29
Anonymous
in reply to: danny.boy.1

With a XData tag you can find the object even after the object moves
from drawing to drawing, which happens in the real world.

{quote}

With a reasonabe amount of programming skill and experience
with ObjectARX, one can do that without having to attach *any*
data to the object.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone"); Edited by: Discussion_Admin on May 29, 2009 10:25 AM
Message 19 of 29
Anonymous
in reply to: danny.boy.1

1 out of 3?



Most of us are already familar with and tired of that , which
often results in drawings containing thousands of APPIDS that slow
down the lookup of any APPID, not to mention slow down saves
and loads and reading of any XDATA.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");


"Terry W. Dotson" wrote in message
news:6190756@discussion.autodesk.com...
Tony Tanzillo wrote:

> 3. It takes much longer to locate an object given the 'unique'
> identifier, as opposed to using handles.

The difference is very small as AutoCAD is quite *fast* at returning
objects that match an AppID.

Terry Edited by: Discussion_Admin on May 29, 2009 10:32 AM
Message 20 of 29
danny.boy.1
in reply to: danny.boy.1

Hello

I think XDATA are enough for me.

With XDATA I can attach only one caracter ("a") to object,

and after copy, move between autocad drawing I can always
to know that object is "my".

Objects with XDATA I will draw progmaticaly, with vb.net. I need
only XDATA fot line and polyline.

Best regards
Danijel Ivankovic

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost