Hello,
I'm new to AutoCAD and programming for AutoCAD. But I'm being given the chance to learn which is great! I've been given code for our plugin which has special tools we need for our application. I'm trying to maintain and add functionality to this.
I just ran across something that I'm not familiar with, which is an ObjectID.Handle? What's it's use over or different from an ObjectID?
Side note, is there a good place to ask these kind of simple questions, since I'll prob have many? Or a good resource to use to look these things up?
Hi,
The Handle is a persisitent indentifier which is unique per drawing.
The ObjectId is a non-persitent identifier (reassigned each time the drawing is opened) which is unique per session.
In an AutoCAD session, you can get the Handle of a DBObject from its ObjectId using the ObjectId.Handle property.
On the other hand, you can get the the ObjectId of a DBObject from its Handle (and its Database) with the Database.GetObjectId() method.
Thank you very much, that is a great answer. Where would one find this information so I don't need to ask these small questions?
Thanks for your help!
All the links provided in my previous messsge come from here:
https://help.autodesk.com/view/OARX/2022/ENU/
Specifically 'ObjectARX Managed .NET Developer's Guide' and 'ObjectARX Managed .NET Reference Guide' sections.
From myself I will add that if you open multiple drawings, the handle may have the same value for different objects in different drawings. ObjectId is unique even if you have multiple drawings open and several different objects in the diferrent drawings have a handle with the same value. You have to be very careful to avoid confusion by using the handle between different drawings.
If you want a store a handle of an object in a drawing (in Xrecord for example), always use handle because it is unique and constatnt in the drawing. Handle shall be unique in the drawing, even if you delete the object and add a new one. If you want to open object, use the ObjectId, because it is unique among drawings.
Can't find what you're looking for? Ask the community or share your knowledge.