Extended Data (XDATA)ΒΆ

Extended data (XDATA) is a DXF tags structure to store arbitrary data in DXF entities. The XDATA is associated to an AppID and only one tag list is supported for each AppID per entity.

Warning

Low level usage of XDATA is an advanced feature, it is the responsibility of the programmer to create valid XDATA structures. Any errors can invalidate the DXF file!

This section shows how to store DXF tags directly in DXF entity but there is also a more user friendly and safer way to store custom XDATA in DXF entities:

Use the high level methods of DXFEntity to manage XDATA tags.

Get XDATA tags as a ezdxf.lldxf.tags.Tags data structure, without the mandatory first tag (1001, AppID):

if entity.has_xdata("EZDXF"):
    tags = entity.get_xdata("EZDXF")

# or use alternatively:
try:
    tags = entity.get_xdata("EZDXF")
except DXFValueError:
    # XDATA for "EZDXF" does not exist
    ...

Set DXF tags as list of (group code, value) tuples or as ezdxf.lldxf.tags.Tags data structure, valid DXF tags for XDATA are documented in the section about the Extended Data internals. The mandatory first tag (1001, AppID) is inserted automatically if not present.

Set only new XDATA tags:

if not entity.has_xdata("EZDXF"):
    entity.set_xdata("EZDXF", [(1000, "MyString")])

Replace or set new XDATA tags:

entity.set_xdata("EZDXF", [(1000, "MyString")])

See also