DXF Entity Base Class¶
Common base class for all DXF entities and objects.
Warning
Do not instantiate entity classes by yourself - always use the provided factory functions!
-
class
ezdxf.entities.
DXFEntity
¶ -
dxf
¶ The DXF attributes namespace:
# set attribute value entity.dxf.layer = 'MyLayer' # get attribute value linetype = entity.dxf.linetype # delete attribute del entity.dxf.linetype
-
dxf.
handle
¶ DXF handle is a unique identifier as plain hex string like
F000
. (feature for experts)
-
dxf.
owner
¶ Handle to owner as plain hex string like
F000
. (feature for experts)
-
dxftype
() → str¶ Get DXF type as string, like
LINE
for the line entity.
-
__str__
() → str¶ Returns a simple string representation.
-
__repr__
() → str¶ Returns a simple string representation including the class.
-
has_dxf_attrib
(key: str) → bool¶ Returns
True
if DXF attribute key really exist.Raises
DXFAttributeError
if key is not an supported DXF attribute.
-
is_supported_dxf_attrib
(key: str) → bool¶ Returns
True
if DXF attrib key is supported by this entity. Does not grant that attribute key really exist.
-
get_dxf_attrib
(key: str, default: Optional[Any] = None) → Any¶ Get DXF attribute key, returns default if key doesn’t exist, or raise
DXFValueError
if default isDXFValueError
and no DXF default value is defined:layer = entity.get_dxf_attrib("layer") # same as layer = entity.dxf.layer
Raises
DXFAttributeError
if key is not an supported DXF attribute.
-
set_dxf_attrib
(key: str, value: Any) → None¶ Set new value for DXF attribute key:
entity.set_dxf_attrib("layer", "MyLayer") # same as entity.dxf.layer = "MyLayer"
Raises
DXFAttributeError
if key is not an supported DXF attribute.
-
del_dxf_attrib
(key: str) → None¶ Delete DXF attribute key, does not raise an error if attribute is supported but not present.
Raises
DXFAttributeError
if key is not an supported DXF attribute.
-
dxfattribs
(drop: Optional[set[str]] = None) → dict¶ Returns a
dict
with all existing DXF attributes and their values and exclude all DXF attributes listed in set drop.
-
update_dxf_attribs
(dxfattribs: dict) → None¶ Set DXF attributes by a
dict
like{'layer': 'test', 'color': 4}
.
-
set_flag_state
(flag: int, state: bool = True, name: str = 'flags') → None¶ Set binary coded flag of DXF attribute name to 1 (on) if state is
True
, set flag to 0 (off) if state isFalse
.
-
get_flag_state
(flag: int, name: str = 'flags') → bool¶ Returns
True
if any flag of DXF attribute is 1 (on), elseFalse
. Always check only one flag state at the time.
-
has_extension_dict
¶ Returns
True
if entity has an attachedExtensionDict
instance.
-
get_extension_dict
() → ezdxf.entities.xdict.ExtensionDict¶ Returns the existing
ExtensionDict
instance.Raises: AttributeError
– extension dict does not exist
-
new_extension_dict
() → ezdxf.entities.xdict.ExtensionDict¶ Create a new
ExtensionDict
instance .
-
discard_extension_dict
() → None¶ Delete
ExtensionDict
instance .
-
has_app_data
(appid: str) → bool¶ Returns
True
if application defined data for appid exist.
-
get_app_data
(appid: str) → ezdxf.lldxf.tags.Tags¶ Returns application defined data for appid.
Parameters: appid – application name as defined in the APPID table. Raises: DXFValueError
– no data for appid found
-
set_app_data
(appid: str, tags: Iterable[T_co]) → None¶ Set application defined data for appid as iterable of tags.
Parameters: - appid – application name as defined in the APPID table.
- tags – iterable of (code, value) tuples or
DXFTag
-
discard_app_data
(appid: str)¶ Discard application defined data for appid. Does not raise an exception if no data for appid exist.
-
has_xdata
(appid: str) → bool¶ Returns
True
if extended data for appid exist.
-
get_xdata
(appid: str) → ezdxf.lldxf.tags.Tags¶ Returns extended data for appid.
Parameters: appid – application name as defined in the APPID table. Raises: DXFValueError
– no extended data for appid found
-
set_xdata
(appid: str, tags: Iterable[T_co]) → None¶ Set extended data for appid as iterable of tags.
Parameters: - appid – application name as defined in the APPID table.
- tags – iterable of (code, value) tuples or
DXFTag
-
discard_xdata
(appid: str) → None¶ Discard extended data for appid. Does not raise an exception if no extended data for appid exist.
-
has_xdata_list
(appid: str, name: str) → bool¶ Returns
True
if a tag list name for extended data appid exist.
-
get_xdata_list
(appid: str, name: str) → ezdxf.lldxf.tags.Tags¶ Returns tag list name for extended data appid.
Parameters: - appid – application name as defined in the APPID table.
- name – extended data list name
Raises: DXFValueError
– no extended data for appid found or no data list name not found
-
set_xdata_list
(appid: str, name: str, tags: Iterable[T_co]) → None¶ Set tag list name for extended data appid as iterable of tags.
Parameters: - appid – application name as defined in the APPID table.
- name – extended data list name
- tags – iterable of (code, value) tuples or
DXFTag
-
discard_xdata_list
(appid: str, name: str) → None¶ Discard tag list name for extended data appid. Does not raise an exception if no extended data for appid or no tag list name exist.
-
replace_xdata_list
(appid: str, name: str, tags: Iterable[T_co]) → None¶ Replaces tag list name for existing extended data appid by tags. Appends new list if tag list name do not exist, but raises
DXFValueError
if extended data appid do not exist.Parameters: - appid – application name as defined in the APPID table.
- name – extended data list name
- tags – iterable of (code, value) tuples or
DXFTag
Raises: DXFValueError
– no extended data for appid found
-
has_reactors
() → bool¶ Returns
True
if entity has reactors.
-
get_reactors
() → list[str]¶ Returns associated reactors as list of handles.
-
set_reactors
(handles: Iterable[str]) → None¶ Set reactors as list of handles.
-
append_reactor_handle
(handle: str) → None¶ Append handle to reactors.
-
discard_reactor_handle
(handle: str) → None¶ Discard handle from reactors. Does not raise an exception if handle does not exist.
-