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.

New in version 0.18.

class ezdxf.render.MultiLeaderBuilder

Abstract base class to build MultiLeader entities.

property context: ezdxf.entities.mleader.MLeaderContext

Returns the context entity MLeaderContext.

property multileader: ezdxf.entities.mleader.MultiLeader

Returns the MultiLeader entity.

add_leader_line(side: ConnectionSide, vertices: Iterable[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: Vec2, rotation: float = 0.0, ucs: Optional[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 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, right=HorizontalConnection.by_style, top=VerticalConnection.by_style, bottom=VerticalConnection.by_style)

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)

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: 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!


scale – scaling factor > 0.0


Specialization of MultiLeaderBuilder to build MultiLeader with MTEXT content.

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

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: Vec2, segment1: Vec2, segment2: Optional[Vec2] = None, connection_type: Union[HorizontalConnection, VerticalConnection] = HorizontalConnection.middle_of_top_line, ucs: Optional[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
property block_layout: BlockLayout

Returns the block layout.

property extents: ezdxf.math.bbox.BoundingBox

Returns the bounding box of the block.

set_content(name: str, color: Union[int, Tuple[int, int, int]] = 0, scale: float = 1.0, alignment=BlockAlignment.center_extents)

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(value)

The leader type.

class ezdxf.render.ConnectionSide(value)

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(value)

The horizontal leader connection type.

class ezdxf.render.VerticalConnection(value)

The vertical leader connection type.

class ezdxf.render.TextAlignment(value)

The MText alignment type.

class ezdxf.render.BlockAlignment(value)

The Block alignment type.