Extension Dictionary

Every entity can have an extension dictionary, which can reference arbitrary DXF objects from the OBJECTS section but not graphical entities. Using this mechanism, several applications can attach data to the same entity. The usage of extension dictionaries is more complex than Extended Data (XDATA) but also more flexible with higher capacity for adding data.

Use the high level methods of DXFEntity to manage extension dictionaries.

The main data storage objects referenced by extension dictionaries are:

class ezdxf.entities.xdict.ExtensionDict

Internal management class for extension dictionaries.

See also

property is_alive

Returns True if the underlying Dictionary object is not deleted.

__contains__(key: str)

Return key in self.

__getitem__(key: str)

Get self[key].

__setitem__(key: str, value)

Set self[key] to value.

Only DXF objects stored in the OBJECTS section are allowed as content of the extension dictionary. DXF entities stored in layouts are not allowed.

Raises

DXFTypeError – invalid DXF type

__delitem__(key: str)

Delete self[key], destroys referenced entity.

__len__()

Returns count of extension dictionary entries.

get(key: str, default=None) Optional[DXFEntity]

Return extension dictionary entry key.

keys()

Returns a KeysView of all extension dictionary keys.

items()

Returns an ItemsView for all extension dictionary entries as (key, entity) pairs. An entity can be a handle string if the entity does not exist.

discard(key: str) None

Discard extension dictionary entry key.

add_dictionary(name: str, hard_owned: bool = True) Dictionary

Create a new Dictionary object as extension dictionary entry name.

add_dictionary_var(name: str, value: str) DictionaryVar

Create a new DictionaryVar object as extension dictionary entry name.

add_xrecord(name: str) XRecord

Create a new XRecord object as extension dictionary entry name.

Link obj to the extension dictionary as entry name.

Linked objects are owned by the extensions dictionary and therefore cannot be a graphical entity, which have to be owned by a BaseLayout.

Raises

DXFTypeErrorobj has invalid DXF type

destroy()

Destroy the underlying Dictionary object.