These are helper classes to build MultiLeader entities in an easy way. The MultiLeader entity supports two kinds of content, for each exist a specialized builder class:

The usual steps of the building process are:

The Tutorial for MultiLeader shows how to use these helper classes in more detail.

class ezdxf.render.MultiLeaderBuilder

Abstract base class to build MultiLeader entities.

add_leader_line(side: ezdxf.render.mleader.ConnectionSide, vertices: Iterable[ezdxf.math._vector.Vec2]) → None

Add leader as iterable of vertices in render UCS coordinates (WCS by default).


Vertical (top, bottom) and horizontal attachment sides (left, right) can not be mixed in a single entity - this is a limitation of the MULTILEADER entity.

  • side – connection side where to attach the leader line
  • vertices – leader vertices
build(insert: ezdxf.math._vector.Vec2, rotation: float = 0.0, ucs: Optional[ezdxf.math.ucs.UCS] = None) → None

Compute the required geometry data. The construction plane is the xy-plane of the given render UCS.

  • insert – insert location for the content in render UCS coordinates
  • rotation – content rotation angle around the render UCS z-axis in degrees
  • ucs – the render UCS, default is the WCS
set_arrow_properties(name: str = '', size: float = 0.0)

Set leader arrow properties all leader lines have the same arrow type.

The MULTILEADER entity is able to support multiple arrows, but this seems to be unsupported by CAD applications and is therefore also not supported by the builder classes.

set_connection_properties(landing_gap: float = 0.0, dogleg_length: float = 0.0)

Set the properties how to connect the leader line to the content.

The landing gap is the space between the content and the start of the leader line. The “dogleg” is the first line segment of the leader in the “horizontal” direction of the content.

set_connection_types(left=<HorizontalConnection.by_style: -1>, right=<HorizontalConnection.by_style: -1>, top=<VerticalConnection.by_style: 0>, bottom=<VerticalConnection.by_style: 0>)

Set the connection type for each connection side.

set_leader_properties(color: Union[int, Tuple[int, int, int]] = 0, linetype: str = 'BYBLOCK', lineweight: int = -2, leader_type=<LeaderType.straight_lines: 1>)

Set leader line properties.

  • color – line color as AutoCAD Color Index (ACI) or RGB tuple
  • linetype – as name string, e.g. “BYLAYER”
  • lineweight – as integer value, see: Lineweights
  • leader_type – straight lines of spline type
set_mleader_style(style: ezdxf.entities.mleader.MLeaderStyle)

Reset base properties by MLeaderStyle properties. This also resets the content!

set_overall_scaling(scale: float)

Set the overall scaling factor for the whole entity, except for the leader line vertices!

Parameters:scale – scaling factor > 0.0


Specialization of MultiLeaderBuilder to build MultiLeader with MTEXT content.

class ezdxf.render.MultiLeaderMTextBuilder
set_content(content: str, color: Union[int, Tuple[int, int, int], None] = None, char_height: float = 0.0, alignment: ezdxf.render.mleader.TextAlignment = <TextAlignment.left: 1>, style: str = '')

Set MTEXT content.

  • content – MTEXT content as string
  • color – block color as AutoCAD Color Index (ACI) or RGB tuple
  • char_height – initial char height in drawing units
  • alignmentTextAlignment - left, center, right
  • style – name of Textstyle as string
quick_leader(content: str, target: ezdxf.math._vector.Vec2, segment1: ezdxf.math._vector.Vec2, segment2: Optional[ezdxf.math._vector.Vec2] = None, connection_type: Union[ezdxf.render.mleader.HorizontalConnection, ezdxf.render.mleader.VerticalConnection] = <HorizontalConnection.middle_of_top_line: 1>, ucs: Optional[ezdxf.math.ucs.UCS] = None) → None

Creates a quick MTEXT leader. The target point defines where the leader points to. The segment1 is the first segment of the leader line relative to the target point, segment2 is an optional second line segment relative to the first line segment. The connection_type defines the type of connection (horizontal or vertical) and the MTEXT alignment (left, center or right). Horizontal connections are always left or right aligned, vertical connections are always center aligned.

  • content – MTEXT content string
  • target – leader target point as Vec2
  • segment1 – first leader line segment as relative distance to insert
  • segment2 – optional second leader line segment as relative distance to first line segment
  • connection_type – one of HorizontalConnection or VerticalConnection
  • ucs – the rendering UCS, default is the WCS


Specialization of MultiLeaderBuilder to build MultiLeader with BLOCK content.

class ezdxf.render.MultiLeaderBlockBuilder
set_content(name: str, color: Union[int, Tuple[int, int, int]] = 0, scale: float = 1.0, alignment=<BlockAlignment.center_extents: 0>)

Set BLOCK content.

  • name – the block name as string
  • color – block color as AutoCAD Color Index (ACI) or RGB tuple
  • scale – the block scaling, not to be confused with overall scaling
  • alignment – the block insertion point or the center of extents
set_attribute(tag: str, text: str, width: float = 1.0)

Add BLOCK attributes based on an ATTDEF entity in the block definition. All properties of the new created ATTRIB entity are defined by the template ATTDEF entity including the location.

  • tag – attribute tag name
  • text – attribute content string
  • width – width factor


class ezdxf.render.LeaderType

The leader type.

class ezdxf.render.ConnectionSide

The leader connection side.

Vertical (top, bottom) and horizontal attachment sides (left, right) can not be mixed in a single entity - this is a limitation of the MULTILEADER entity.

class ezdxf.render.HorizontalConnection

The horizontal leader connection type.

class ezdxf.render.VerticalConnection

The vertical leader connection type.

class ezdxf.render.TextAlignment

The MText alignment type.

class ezdxf.render.BlockAlignment

The Block alignment type.