Dictionary¶
The DICTIONARY is a general storage entity.
AutoCAD maintains items such as MLINE_STYLES and GROUP definitions as objects in dictionaries.
Other applications are free to create and use their own dictionaries as they see fit.
The prefix 'ACAD_' is reserved for use by AutoCAD applications.
Dictionary entries are (key, DXFEntity) pairs. At loading time the value could be a str,
because at this time not all objects are already stored in the EntityDB, and have to be acquired later.
Subclass of |
|
DXF type |
|
Factory function |
Warning
Do not instantiate object classes by yourself - always use the provided factory functions!
-
class
ezdxf.entities.Dictionary¶ -
dxf.hard_owned¶ If set to
1, indicates that elements of the dictionary are to be treated as hard-owned.
-
dxf cloning Duplicate record cloning flag (determines how to merge duplicate entries, ignored by ezdxf):
0
not applicable
1
keep existing
2
use clone
3
<xref>$0$<name>
4
$0$<name>
5
Unmangle name
-
is_hard_owner¶ Returns
TrueifDictionaryis hard owner of entities. Hard owned entities will be destroyed by deleting the dictionary.
-
__len__() → int¶ Returns count of items.
-
__contains__(key: str) → bool¶ Returns
Trueif key exist.
-
__getitem__(key: str) → DXFEntity¶ Return the value for key, raises a
DXFKeyErrorif key does not exist.
-
__delitem__(key: str) → None¶ Delete entry key from the dictionary, raises
DXFKeyErrorif key does not exist.
-
keys() → KeysView¶ Returns
KeysViewof all dictionary keys.
-
count() → int¶ Returns count of items.
-
get(key: str, default: Any = DXFKeyError) → DXFEntity¶ Returns
DXFEntityfor key, if key exist, else default or raises aDXFKeyErrorfor default =DXFKeyError.
-
remove(key: str) → None¶ Delete entry key. Raises
DXFKeyError, if key does not exist. Deletes also hard owned DXF objects from OBJECTS section.
-
discard(key: str) → None¶ Delete entry key if exists. Does NOT raise an exception if key not exist and does not delete hard owned DXF objects.
-
clear() → None¶ Delete all entries from
Dictionary, deletes hard owned DXF objects from OBJECTS section.
-
add_new_dict(key: str, hard_owned: bool = False) → Dictionary¶ Create a new sub
Dictionary.- Parameters
key – name of the sub dictionary
hard_owned – entries of the new dictionary are hard owned
-
get_required_dict(key: str) → Dictionary¶ Get entry key or create a new
Dictionary, if Key not exist.
-
add_dict_var(key: str, value: str) → DictionaryVar¶ Add new
DictionaryVar.- Parameters
key – entry name as string
value – entry value as string
-
DictionaryWithDefault¶
Subclass of |
|
DXF type |
|
Factory function |
|