Can the DXF file format/AutoCAD store custom attributes for primitives?

2

I am currently researching ways to draw primitives associated with data attributes. Thus I came across CAD and the DXF file format, but I am no CAD user, and the documentation I found so far is confusing me in this regard.

So my question is, can I add attributes to a drawn primitive in AutoCAD? E.g. can I draw a polygon and give it a custom attribute like "material = metal"?

I only know such functionality from GIS programs and file formats like GeoJSON, however, these programs are highly specialized for drawings in a bird perspective, without constructional precision (i.e. angles, length, etc.).

So is this possible to do in AutoCAD, and than save the result as a DXF ASCII?

Thank you for your time, and please excuse me for my ignorance

tkr

Posted 2014-08-04T13:41:18.613

Reputation: 23

Answers

1

Yes, you can achieve this using Extended Entity Data (xData).

There are various ways to attach xdata to an object: the easiest of which and which requires no programming experience is to use the Express Tools' XDATA command.

Upon invoking this command you will be prompted to specify an application name (App ID) under which the xdata will be attached. The application name can be arbitrary, but avoid anything starting with "ACAD" (these are reserved for use by AutoCAD, for example, to apply Dimension Style overrides) and avoid spaces and symbols.

You will then be prompted to choose the data type for the data that you are attaching to the object. The available data types are displayed as keywords at the command-line.

Finally, upon specifying the data type, AutoCAD will prompt you in an appropriate way to specify the data to be attached to the object, stored under the Application ID specified.

To extract the stored data, you can either use the Express Tools' XDLIST command, or you can access the xData programmatically, as I have described here.

Lee Mac

Posted 2014-08-04T13:41:18.613

Reputation: 763