AttDef

The ATTDEF (DXF Reference) entity is a template in a BlockLayout, which will be used to create an attached Attrib entity for an Insert entity.

Subclass of ezdxf.entities.Text
DXF type 'ATTDEF'
Factory function ezdxf.layouts.BaseLayout.add_attdef()
Inherited DXF attributes Common graphical DXF attributes

Warning

Do not instantiate entity classes by yourself - always use the provided factory functions!

class ezdxf.entities.AttDef

ATTDEF supports all DXF attributes and methods of parent class Text.

dxf.tag

Tag to identify the attribute (str)

dxf.text

Attribute content as text (str)

dxf.prompt

Attribute prompt string. (CAD application feature)

dxf.field_length

Just relevant to CAD programs for validating user input

virtual_mtext_entity() → ezdxf.entities.mtext.MText

Returns the embedded MTEXT entity as a regular but virtual MText entity with the same graphical properties as the host entity.

plain_mtext(fast=True) → str

Returns the embedded MTEXT content without formatting codes. Returns an empty string if no embedded MTEXT entity exist.

The “fast” mode is accurate if the DXF content was created by reliable (and newer) CAD applications like AutoCAD or BricsCAD. The “accurate” mode is for some rare cases where the content was created by older CAD applications or unreliable DXF libraries and CAD applications.

The “accurate” mode is much slower than the “fast” mode.

Parameters:fast – uses the “fast” mode to extract the plain MTEXT content if True or the “accurate” mode if set to False
set_mtext(mtext: ezdxf.entities.mtext.MText, graphic_properties=True) → None

Set multi-line properties from a MText entity.

The multi-line ATTRIB/ATTDEF entity requires DXF R2018, otherwise an ordinary single line ATTRIB/ATTDEF entity will be exported.

Parameters:
  • mtext – source MText entity
  • graphic_properties – copy graphic properties (color, layer, …) from source MTEXT if True
embed_mtext(mtext: ezdxf.entities.mtext.MText, graphic_properties=True) → None

Set multi-line properties from a MText entity and destroy the source entity afterwards.

The multi-line ATTRIB/ATTDEF entity requires DXF R2018, otherwise an ordinary single line ATTRIB/ATTDEF entity will be exported.

Parameters:
  • mtext – source MText entity
  • graphic_properties – copy graphic properties (color, layer, …) from source MTEXT if True