Type: Basic DXF R12 entity.

A block is a collection of objects grouped together to form a single object. You can insert this collection more than once in the same drawing, and when you do, all instances of the block remain identical. You can add fill-in-the-blank text fields, called attributes, to blocks.

A block definition lives in an invisible area of your drawing file called the block table. The block table is like a book of graphical recipes for making different kinds of blocks. Each block definition is like a recipe for making one kind of block. To insert a block into a drawing you have to create a block reference by INSERT.

You have to add the block definition to the blocks section of the actual drawing:


The base point is the point on the block by which you insert it later.

Find a block definition:


Add entities to a block definition:

DXFEngine.block(name, basepoint=(0., 0.), **kwargs)
  • name (str) – blockname
  • basepoint – block base point (xy- or xyz-tuple), z-axis is 0. by default
  • flags (int) – block type flags
  • xref (str) – xref pathname

where entity can be every drawing entity like circle, line, polyline, attribute, text, ...


Flags Description
BLK_ANONYMOUS This is an anonymous block generated by hatching, associative dimensioning, other internal operations, or an application
BLK_NON_CONSTANT_ATTRIBUTES This block has non-constant attribute definitions (this bit is not set if the block has any attribute definitions that are constant, or has no attribute definitions at all)
BLK_XREF This block is an external reference (xref)
BLK_XREF_OVERLAY This block is an xref overlay
BLK_EXTERNAL This block is externally dependent
BLK_RESOLVED This is a resolved external reference, or dependent of an external reference (ignored on input)
BLK_REFERENCED This definition is a referenced external reference (ignored on input)

Common Keyword Arguments for all Basic DXF R12 Entities

keyword description
layer Layer name as string
linetype Linetype name as string, if not defined = BYLAYER
color as integer in range [1..255], 0 = BYBLOCK, 256 = BYLAYER
thickness Thickness as float
paper_space 0 = entity is in model_space, 1 = entity is in paper_space
extrusion_direction 3D Point as tuple(x, y, z) if extrusion direction is not parallel to the World Z axis


from dxfwrite import DXFEngine as dxf

drawing = dxf.drawing('test.dxf')

# create a block-definition
block = dxf.block(name='BLOCK1')

# add block-definition to drawing

# create a block-reference
blockref = dxf.insert(blockname='BLOCK1', insert=(10, 10))

# add block-reference to drawing