class Insert

A block reference (DXF type: INSERT) with the possibility to append attributes (Attrib).

DXF Attributes for Insert

Common DXF Attributes for DXF R12

Common DXF Attributes for DXF R13 or later

TODO: influence of layer, linetype, color DXF attributes to block entities

Block name (str)


Insertion point as (2D/3D Point in OCS)


Scale factor for x direction (float)


Scale factor for y direction (float)


Scale factor for z direction (float)


Rotation angle in degrees (float)


Count of repeated insertions in row direction (int)


Distance between two insert points in row direction (float)


Count of repeated insertions in column direction (int)


Distance between two insert points in column direction (float)

Insert Methods, scale=None, rotation=None)

Place block reference as point insert with scaling and rotation. scale has to be a (x, y, z)-tuple and rotation a rotation angle in degrees. Parameters which are None will not be altered.

Insert.grid(size=(1, 1), spacing=(1, 1))

Place block references in a grid layout with grid size=(rows, columns)-tuple and spacing=(row_spacing, column_spacing)-tuple. spacing is the distance from insertion point to insertion point.


Iterate over appended Attrib objects.

Insert.has_attrib(tag, search_const=False)

Returns True if an attrib tag exists else False, for search_const doc see Insert.get_attrib().

Insert.get_attrib(tag, search_const=False)

Get the appended Attrib object with object.dxf.tag == tag, returns None if not found. Some applications may not attach Attrib, which do represent constant values, set search_const=True and you get at least the associated Attdef entity.

Insert.get_attrib_text(tag, default=None, search_const=False)

Get content text for attrib tag as string or return default if no attrib tag exists, for search_const doc see Insert.get_attrib().

Insert.add_attrib(tag, text, insert=(0, 0), attribs={})

Append an Attrib to the block reference. Returns an Attrib object.

Example for appending an attribute to an INSERT entity with none standard alignment:

insert_entity.add_attrib("TAG", "example text").set_pos((3, 7), align='MIDDLE_CENTER')
Insert.delete_attrib(tag, ignore=False)

Delete an Attrib from Insert. If ignore is False, an DXFKeyError exception is raised, if Attrib tag does not exist.


Delete all attached Attrib entities.