Insert

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

Insert.dxf.name

Block name (str)

Insert.dxf.insert

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

Insert.dxf.xscale

Scale factor for x direction (float)

Insert.dxf.yscale

Scale factor for y direction (float)

Insert.dxf.zscale

Scale factor for z direction (float)

Insert.dxf.rotation

Rotation angle in degrees (float)

Insert.dxf.row_count

Count of repeated insertions in row direction (int)

Insert.dxf.row_spacing

Distance between two insert points in row direction (float)

Insert.dxf.column_count

Count of repeated insertions in column direction (int)

Insert.dxf.column_spacing

Distance between two insert points in column direction (float)

Insert Methods

Insert.place(insert=None, 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.

Insert.attribs()

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.

Insert.delete_all_attribs()

Delete all attached Attrib entities.