- class ezdxf.lldxf.tags.Tags¶
Subclass of
list
.Collection of
DXFTag
as flat list. Low level tag container, only required for advanced stuff.- dxftype() str ¶
Returns DXF type of entity, e.g.
'LINE'
.
- get_handle() str ¶
Get DXF handle. Raises
DXFValueError
if handle not exist.- Returns:
handle as plain hex string like
'FF00'
- Raises:
DXFValueError – no handle found
- replace_handle(new_handle: str) None ¶
Replace existing handle.
- Parameters:
new_handle – new handle as plain hex string e.g.
'FF00'
- has_tag(code: int) bool ¶
Returns
True
if aDXFTag
with given group code is present.- Parameters:
code – group code as int
- has_embedded_objects() bool ¶
- get_first_tag(code: int, default=DXFValueError) DXFTag ¶
Returns first
DXFTag
with given group code or default, if default !=DXFValueError
, else raisesDXFValueError
.- Parameters:
code – group code as int
default – return value for default case or raises
DXFValueError
- get_first_value(code: int, default=DXFValueError) Any ¶
Returns value of first
DXFTag
with given group code or default if default !=DXFValueError
, else raisesDXFValueError
.- Parameters:
code – group code as int
default – return value for default case or raises
DXFValueError
- find_all(code: int) List[DXFTag] ¶
Returns a list of
DXFTag
with given group code.- Parameters:
code – group code as int
- filter(codes: Iterable[int]) Iterable[DXFTag] ¶
Iterate and filter tags by group codes.
- Parameters:
codes – group codes to filter
- collect_consecutive_tags(codes: Iterable[int], start: int = 0, end: int = None) Tags ¶
Collect all consecutive tags with group code in codes, start and end delimits the search range. A tag code not in codes ends the process.
- Parameters:
codes – iterable of group codes
start – start index as int
end – end index as int,
None
for end index =len(self)
- Returns:
collected tags as
Tags
- tag_index(code: int, start: int = 0, end: int | None = None) int ¶
Return index of first
DXFTag
with given group code.- Parameters:
code – group code as int
start – start index as int
end – end index as int,
None
for end index =len(self)
- update(tag: DXFTag)¶
Update first existing tag with same group code as tag, raises
DXFValueError
if tag not exist.
- remove_tags(codes: Iterable[int]) None ¶
Remove all tags inplace with group codes specified in codes.
- Parameters:
codes – iterable of group codes as int
- remove_tags_except(codes: Iterable[int]) None ¶
Remove all tags inplace except those with group codes specified in codes.
- Parameters:
codes – iterable of group codes
- ezdxf.lldxf.tags.group_tags(tags: Iterable[DXFTag], splitcode: int = 0) Iterable[Tags] ¶
Group of tags starts with a SplitTag and ends before the next SplitTag. A SplitTag is a tag with code == splitcode, like (0, ‘SECTION’) for splitcode == 0.
- Parameters:
tags – iterable of
DXFTag
splitcode – group code of split tag
- class ezdxf.lldxf.extendedtags.ExtendedTags(tags: Iterable[DXFTag] = None, legacy=False)¶
Represents the extended DXF tag structure introduced with DXF R13.
- Args:
tags: iterable of
DXFTag
legacy: flag for DXF R12 tags
- appdata¶
Application defined data as list of
Tags
- subclasses¶
Subclasses as list of
Tags
- xdata¶
XDATA as list of
Tags
- embedded_objects¶
embedded objects as list of
Tags
- noclass¶
Short cut to access first subclass.
- get_handle() str ¶
Returns handle as hex string.
- dxftype() str ¶
Returns DXF type as string like “LINE”.
- replace_handle(handle: str) None ¶
Replace the existing entity handle by a new value.
- legacy_repair()¶
Legacy (DXF R12) tags handling and repair.
- clone() ExtendedTags ¶
Shallow copy.
- flatten_subclasses()¶
Flatten subclasses in legacy mode (DXF R12).
There exists DXF R12 with subclass markers, technical incorrect but works if the reader ignore subclass marker tags, unfortunately ezdxf tries to use this subclass markers and therefore R12 parsing by ezdxf does not work without removing these subclass markers.
This method removes all subclass markers and flattens all subclasses into ExtendedTags.noclass.
- get_subclass(name: str, pos: int = 0) Tags ¶
Get subclass name.
- Parameters:
name – subclass name as string like “AcDbEntity”
pos – start searching at subclass pos.
- has_xdata(appid: str) bool ¶
True
if has XDATA for appid.
- set_xdata(appid: str, tags: IterableTags) None ¶
Set tags as XDATA for appid.
- new_xdata(appid: str, tags: 'IterableTags' = None) Tags ¶
Append a new XDATA block.
Assumes that no XDATA block with the same appid already exist:
try: xdata = tags.get_xdata('EZDXF') except ValueError: xdata = tags.new_xdata('EZDXF')
- has_app_data(appid: str) bool ¶
True
if has application defined data for appid.
- get_app_data(appid: str) Tags ¶
Returns application defined data for appid as
Tags
including marker tags.
- get_app_data_content(appid: str) Tags ¶
Returns application defined data for appid as
Tags
without first and last marker tag.
- set_app_data_content(appid: str, tags: IterableTags) None ¶
Set application defined data for appid for already exiting data.
- new_app_data(appid: str, tags: 'IterableTags' = None, subclass_name: str = None) Tags ¶
Append a new application defined data to subclass subclass_name.
Assumes that no app data block with the same appid already exist:
try: app_data = tags.get_app_data('{ACAD_REACTORS', tags) except ValueError: app_data = tags.new_app_data('{ACAD_REACTORS', tags)
- classmethod from_text(text: str, legacy: bool = False) ExtendedTags ¶
Create
ExtendedTags
from DXF text.