Attrib

The ATTRIB (DXF Reference) entity represents a text value associated with a tag. In most cases an ATTRIB is appended to an Insert entity, but it can also appear as standalone entity.

Subclass of ezdxf.entities.Text
DXF type 'ATTRIB'
Factory function ezdxf.layouts.BaseLayout.add_attrib() (stand alone entity)
Factory function Insert.add_attrib() (attached to Insert)
Inherited DXF attributes Common graphical DXF attributes

Warning

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

class ezdxf.entities.Attrib

ATTRIB 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)

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