DXF Types

Required DXF tag interface:

  • property code: group code as int

  • property value: tag value of unspecific type

  • dxfstr(): returns the DXF string

  • clone(): returns a deep copy of tag

DXFTag Factory Functions

ezdxf.lldxf.types.dxftag(code: int, value: Any) DXFTag

DXF tag factory function.

Parameters:
  • code – group code

  • value – tag value

Returns: DXFTag or inherited

ezdxf.lldxf.types.tuples_to_tags(iterable: Iterable[tuple[int, Any]]) Iterable[DXFTag]

Returns an iterable if DXFTag or inherited, accepts an iterable of (code, value) tuples as input.

DXFTag

class ezdxf.lldxf.types.DXFTag(code: int, value: Any)

Immutable DXFTag class.

Parameters:
  • code – group code as int

  • value – tag value, type depends on group code

code

group code as int (do not change)

value

tag value (read-only property)

__eq__(other) bool

True if other and self has same content for code and value.

__getitem__(index: int)

Returns code for index 0 and value for index 1, emulates a tuple.

__hash__()

Hash support, DXFTag can be used in sets and as dict key.

__iter__()

Returns (code, value) tuples.

__repr__() str

Returns representation string 'DXFTag(code, value)'.

__str__() str

Returns content string '(code, value)'.

clone() DXFTag

Returns a clone of itself, this method is necessary for the more complex (and not immutable) DXF tag types.

dxfstr() str

Returns the DXF string e.g. '  0\nLINE\n'

DXFBinaryTag

class ezdxf.lldxf.types.DXFBinaryTag(DXFTag)

Immutable BinaryTags class - immutable by design, not by implementation.

dxfstr() str

Returns the DXF string for all vertex components.

tostring() str

Returns binary value as single hex-string.

DXFVertex

class ezdxf.lldxf.types.DXFVertex(DXFTag)

Represents a 2D or 3D vertex, stores only the group code of the x-component of the vertex, because the y-group-code is x-group-code + 10 and z-group-code id x-group-code+20, this is a rule that ALWAYS applies. This tag is immutable by design, not by implementation.

Parameters:
  • code – group code of x-component

  • value – sequence of x, y and optional z values

dxfstr() str

Returns the DXF string for all vertex components.

dxftags() Iterable[DXFTag]

Returns all vertex components as single DXFTag objects.

NONE_TAG

ezdxf.lldxf.types.NONE_TAG

Special tag representing a none existing tag.