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

XDATA - order of records always same?

8 REPLIES 8
Reply
Message 1 of 9
Anonymous
837 Views, 8 Replies

XDATA - order of records always same?

Hi,

 

I found out that I need to use XDATA but I'm not familiar with it and couldn't find an answer anywhere else.

 

An application - AC Map - creates XDATA when performing a specific export.Originally the data is stored in a table. As XDATA it looks like that (for one entity):

...

* Registered Application Name: SAVE_MAP_TO_AUTOCAD
* Code 1000, ASCII string: _SCHEMA_NAME
* Code 1000, ASCII string: WT_FM
* Code 1000, ASCII string: _TABLE_NAME
* Code 1000, ASCII string: FM_V_DSP_SW_TRASSEKANTE
...
* Code 1000, ASCII string: FID
* Code 1040, Real number: 118058
* Code 1000, ASCII string: JOB_VERSION
* Code 1040, Real number: 83917
...
...

 

For certain objects (plines) I need to look up a value stored as XDATA. So I will loop through the xdata of a pline until I find the table column name (e.g. "JOB_VERSION"). When found I know that the next Xdata will be the actual data  I'm looking for (e.g. "83917").

Can I be sure that the order of Xdata records is always the same (as long as application which creates it doesn't change order) when looping throught it and all other plines in my drawing? Is the order set when creating xdata? Or is there no "order"?

 

 

Many thanks, Rob

 

 

 

8 REPLIES 8
Message 2 of 9
Anonymous
in reply to: Anonymous

Hi,
below links would be useful for you. here you can find how to get and set Xdata.

http://through-the-interface.typepad.com/through_the_interface/2007/04/adding_xdata_to.html
Message 3 of 9
Anonymous
in reply to: Anonymous

Hi,

 

I had a look at Keans blog and used some code from there as well. But it doesn't help me with my problem / question.

Basically - how can I make sure I always get the xdata bit I need? Can I only iterate over xdata for an entity? There is no key/value mechanism?

 

Thanks, Rob

 

Message 4 of 9
dgorsman
in reply to: Anonymous

That depends on how the information is stored.  Under worst (or ideal) case sitatuion you would never depend on a specific order e.g. third item is always value "X".  Instead there would be unique DXF index codes for each value.  If you look at the DXF documentation for XDATA values, you will see that each type has a range of numbers.  Well planned storage would make use of those so instead of finding the third value you would iterate looking for that specific DXF code.  If that isn't the case and you *are* dependant on index values then its a good idea to do some error checking on returned values e.g. expected DXF value, expected range of data values, and so on.

----------------------------------
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 5 of 9
Anonymous
in reply to: Anonymous

Hi,

 

do you mean the codes shown in my first posting? The problem is that the codes are not unique - e.g. code 1040 appears twice.

I cannot influence the structure of the xdata - it is produced by AC Map. Or do you refer to another kind of code?

I just had a quick look a DXF reference and I can only find the codes I already noticed in my data. But that wouldn't be of any help?

 

 

Rob

Message 6 of 9
dgorsman
in reply to: Anonymous

As I mentioned above, if you have no control over the order you can only hope that the creation is consistent and provide some error checking to ensure you are getting an appropriate value.

----------------------------------
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 7 of 9
hgasty1001
in reply to: Anonymous

Hi,

 

If the xdata was well defined, it should be structured inside braces {} associated to code 1002, so, you should see something like this ...(1002 . "{")(10XX . value)...(1002 . "}") for each "record" of data. May be if you post a sample drawing we can help you trying to undestand the structure of the data. Any way you can check the data with this lisp: (entget (car(entsel)) '("*"))

 

Gaston Nunez

Message 8 of 9
Anonymous
in reply to: hgasty1001

In helps files and documentation you read something similar to "To add xdata you must register or use a application name that is registed in AppId table or RegappTable". To put it another a way you first store your key in the Regapp table to keep duplicates or so an application knows that the key has already been assigned.

 

So your key is the "application name"

The value is data that follows.

 

The group codes are for storing and identifying the data.

That way you store many data types and the type can be known.

If were just stored as objects or void* how would AutoCAD know if the data is a number or an ObjectId that would need to remapped?

 

If you add xdata to an entity it will be in same order as added to the result buffer which is a linked-list because as you guessed it contains different data types and would not lay out sequential in memory.

 

 

I know I can't trust myself to keep things straight, but if the developer added it 5th in chain then it would be 6th if you count application name, but AutoCAD will not move it around.

 

 

Message 9 of 9
Anonymous
in reply to: Anonymous

Hi,

 

many thanks to all of you. I need to dig a bit deeper but I have got a better understanding now to start from,

 

Have a nice day,

Rob

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

Post to forums  

Forma Design Contest


Autodesk Design & Make Report