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
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
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.
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
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.
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
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.
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.