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)
-
is_alive¶ Returns
Falseif entity has been deleted.
-
is_virtual¶ Returns
Trueif entity is a virtual entity.
-
is_bound¶ Returns
Trueif entity is bound to DXF document.
-
dxftype() → str¶ Get DXF type as string, like
LINEfor 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
Trueif DXF attribute key really exist.Raises
DXFAttributeErrorif key is not an supported DXF attribute.
-
is_supported_dxf_attrib(key: str) → bool¶ Returns
Trueif DXF attrib key is supported by this entity. Does not grant that attribute key really exist.
-
get_dxf_attrib(key: str, default: Any = None) → Any¶ Get DXF attribute key, returns default if key doesn’t exist, or raise
DXFValueErrorif default isDXFValueErrorand no DXF default value is defined:layer = entity.get_dxf_attrib("layer") # same as layer = entity.dxf.layer
Raises
DXFAttributeErrorif 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
DXFAttributeErrorif 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
DXFAttributeErrorif key is not an supported DXF attribute.
-
dxfattribs(drop: Set[str] = None) → Dict¶ Returns a
dictwith all existing DXF attributes and their values and exclude all DXF attributes listed in set drop.Changed in version 0.12: added drop argument
-
update_dxf_attribs(dxfattribs: Dict) → None¶ Set DXF attributes by a
dictlike{'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 isTrue, set flag to0(off) if state isFalse.
-
get_flag_state(flag: int, name: str = 'flags') → bool¶ Returns
Trueif any flag of DXF attribute is1(on), elseFalse. Always check only one flag state at the time.
-
has_extension_dict¶ Returns
Trueif entity has an attachedExtensionDict.
-
get_extension_dict() → ExtensionDict¶ Returns the existing
ExtensionDict.- Raises
AttributeError – extension dict does not exist
-
new_extension_dict() → ExtensionDict¶
-
has_app_data(appid: str) → bool¶ Returns
Trueif application defined data for appid exist.
-
get_app_data(appid: str) → 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)¶ 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
Trueif extended data for appid exist.
-
get_xdata(appid: str) → 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)¶ 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
Trueif a tag list name for extended data appid exist.
-
get_xdata_list(appid: str, name: str) → 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)¶ 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)¶ Replaces tag list name for existing extended data appid by tags. Appends new list if tag list name do not exist, but raises
DXFValueErrorif 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
Trueif 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.
-