I suppose there may not be a precise answer to this question, but perhaps I can at least understand working with DXF files better...
I need to process DXF files (floor plans) and link the label, which is usually a room name, to the entity representing the specific room.
I have checked the DXF file and there seems to be no link between the two entities. The TEXT
entity has a unique handle (code 5) and it has a soft pointer to another object (I think to the general block definition - code 330) but that is not it. So my questions would be:
do I assume correctly that the only way in this case is to compare the coordinates of the label to coordinates of the "nearest" geometry object? This is doable but what if there are a few overlapping objects - I could see some potential risks there.
Is there a way to include a "precise" link from a text entity to a geometry entity in AutoCAD or similar tools? Perhaps with the use of some attributes? My knowledge of DXF is minimal at this point so if anyone could point me to some documentation or example .dxf files where such "precise link" thing is included, it would be great.
Many thanks!
Is there a way to include a "precise" link from a text entity to a geometry entity in AutoCAD or similar tools? Perhaps with the use of some attributes? My knowledge of DXF is minimal at this point so if anyone could point me to some documentation or example .dxf files where such "precise link" thing is included, it would be great.
There may well be other ways to do what you want. Eg:
Also, AutoCAD has a mechanism called Extended Entity Data which is included in any DXF data file (see the link provided).
AutoCAD provides some tools for working with XDATA
and you can also use third-party extensions like CADPower and GeoTools that have an arsenal of XDATA
tools. And ofcourse, you can write you own plugins to do what you what.
In summary, you could attach the handle
of the TEXT
as XDATA
to the POLYLINE
representing the room. Once you have attached the TEXT
as XDATA
it will be available in the DXF file and you will be able to parse it and locate the handle of the TEXT
element.
It isn't too hard to write a VBA macro to run in AutoCAD that asks you to select the two elements and it then add the text entity handle as the XDATA
. Then you are good to go.