Tags¶
A list of DXFTag
, inherits from Python standard list.
Unlike the statement in the DXF Reference “Do not write programs that rely on
the order given here”, tag order is sometimes essential and some group codes
may appear multiples times in one entity. At the worst case
(Material
: normal map shares group codes with
diffuse map) using same group codes with different meanings.
Subclass of
list
.Collection of
DXFTag
as flat list. Low level tag container, only required for advanced stuff.Constructor from DXF string.
Returns DXF type of entity, e.g.
'LINE'
.
Get DXF handle. Raises
DXFValueError
if handle not exist.Returns: handle as plain hex string like 'FF00'
Raises: DXFValueError
– no handle found
Replace existing handle.
Parameters: new_handle – new handle as plain hex string e.g. 'FF00'
Returns
True
if aDXFTag
with given group code is present.Parameters: code – group code as int
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
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
Returns a list of
DXFTag
with given group code.Parameters: code – group code as int
Iterate and filter tags by group codes.
Parameters: codes – group codes to filter
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
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 first existing tag with same group code as tag, raises
DXFValueError
if tag not exist.
Update first existing tag with group code
tag.code
or append tag.
Remove all tags inplace with group codes specified in codes.
Parameters: codes – iterable of group codes as int
Remove all tags inplace except those with group codes specified in codes.
Parameters: codes – iterable of group codes
Pop tags with group codes specified in codes.
Parameters: codes – iterable of group codes
Constructor from tags, strips all tags with group codes in codes from tags.
Parameters: - tags – iterable of
DXFTag
- codes – iterable of group codes as int
- tags – iterable of
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
- tags – iterable of
Represents the extended DXF tag structure introduced with DXF R13.
- Args:
- tags: iterable of
DXFTag
legacy: flag for DXF R12 tags
Application defined data as list of
Tags
Subclasses as list of
Tags
XDATA as list of
Tags
embedded objects as list of
Tags
Short cut to access first subclass.
Returns handle as hex string.
Returns DXF type as string like “LINE”.
Replace the existing entity handle by a new value.
Legacy (DXF R12) tags handling and repair.
Shallow copy.
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.
Parameters: - name – subclass name as string like “AcDbEntity”
- pos – start searching at subclass pos.
True
if has XDATA for appid.
Returns XDATA for appid as
Tags
.
Set tags as XDATA for appid.
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')
True
if has application defined data for appid.
Returns application defined data for appid as
Tags
including marker tags.
Returns application defined data for appid as
Tags
without first and last marker tag.
Set application defined data for appid for already exiting data.
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)
Create
ExtendedTags
from DXF text.
Packed DXF Tags¶
Store DXF tags in compact data structures as list
or array.array
to reduce memory usage.
Store data in a standard Python
list
.- Args:
- data: iterable of DXF tag values.
Data storage as
list
.
Returns a deep copy.
Setup list from iterable tags.
Parameters: - tags – tag collection as
Tags
- code – group code to collect
- tags – tag collection as
Delete all data values.
TagArray
is a subclass ofTagList
, which store data in anarray.array
. Array type is defined by class variableDTYPE
.- Args:
- data: iterable of DXF tag values.
array.array
type as string
Data storage as
array.array
Replace data by values.
Store vertices in an
array.array('d')
. Vertex size is defined by class variableVERTEX_SIZE
.- Args:
- data: iterable of vertex values as linear list e.g.
[x1, y1, x2, y2, x3, y3, ...]
.
Size of vertex (2 or 3 axis).
Count of vertices.
Get vertex at index, extended slicing supported.
Set vertex point at index, extended slicing not supported.
Delete vertex at index, extended slicing supported.
Returns iterable of vertices.
String representation.
Insert point in front of vertex at index pos.
Parameters: - pos – insert position
- point – point as tuple
Append point.
Extend array by points.
Replace all vertices by points.
Delete all vertices.
Returns a deep copy.
Setup point array from iterable tags.
Parameters: - tags – iterable of
DXFVertex
- code – group code to collect
- tags – iterable of