Hello everyone, let me explain about my problem:
1. My main problem is: Link data between host object and client object.
2. I did some thing below:
a> Created an xdata application, and add it to an object
b> Add information to object by xdata
c> Get information form object's xdata
3. In next step, I tried to link two object by xdata. I do it because I wish when I get information from xdata of host object, I can get information of client object.
Example:
- I have a rebar with diameter, number, distance.
- I created a Polyline
- I added this information above by xdata to Polyline.
- I created a Attribute to show the name of Beam.
Now If I want to get information of xdata of Polyline by get it from Attribute'xData
My question is how to create an unique code for Attribute in xdata and Link this to Polyline. So I try to find a way to create unique code in CAD .NET but I find nothing about this method.
I'm thinking about hex code, but what way to create unique hexcode in xdata or C# when create new attribute or polyline etc.?. Please help me to solve this problem. Thanks you!!!
Solved! Go to Solution.
Solved by norman.yuan. Go to Solution.
Every entity has unique identifier in a drawing database: ObjectId/Handle. I believe you want to keep the link across drawing sessions, thus you would save the "linked" entity's Handle in the "host" entity. In this case, "link" means for any host entity (certain Polylines, in your case), you would add the other entity's Handle in the XData attached (you do not need to anything with the "linked" entity). So, as long as you get a Polyline, your code can check if there is XData with given app name attached, if yes, find the Handle in the XData, then you use the handle to identify which other entity is "linked" to the Polyline. Handle is a hex number and is unique, and AutoCAD has already generated for each entity in drawing, so you do not have to bother produce identifier by yourself.
Norman Yuan
Can't find what you're looking for? Ask the community or share your knowledge.