Get Extended Data from DXF Entities

HEADER Variables

i1 = doc.header["$USERI1"]  # integer
r1 = doc.header["$USERR1"]  # float

XDATA Section

The structure of XDATA is arbitrary and only some structures used by AutoCAD are documented in the DXF reference. Use the Browse command to explore these structures directly in DXF files.

my_app_id = "MY_APP_1"
if line.has_xdata(my_app_id):
    tags = line.get_xdata(my_app_id)
    print(f"{str(line)} has {len(tags)} tags of XDATA for AppID {my_app_id!r}")
    for tag in tags:
        print(tag)

Extension Dictionaries

Like XDATA the structure of extension dictionaries is arbitrary and not documented by the DXF reference.

for line in msp.query("LINE"):
    if line.has_extension_dict:
        # get the extension dictionary
        xdict = line.get_extension_dict()