MLine

The MLINE entity (DXF Reference).

Subclass of ezdxf.entities.DXFGraphic
DXF type 'MLINE'
factory function add_mline()
Inherited DXF attributes Common graphical DXF attributes
Required DXF version DXF R2000 ('AC1015')
class ezdxf.entities.MLine
dxf.style_name

MLineStyle name stored in Drawing.mline_styles dictionary, use set_style() to change the MLINESTYLE and update geometry accordingly.

dxf.style_handle

Handle of MLineStyle, use set_style() to change the MLINESTYLE and update geometry accordingly.

dxf.scale_factor

MLINE scaling factor, use method set_scale_factor() to change the scaling factor and update geometry accordingly.

dxf.justification

Justification defines the location of the MLINE in relation to the reference line, use method set_justification() to change the justification and update geometry accordingly.

Constants defined in ezdxf.lldxf.const:

dxf.justification Value
MLINE_TOP 0
MLINE_ZERO 1
MLINE_BOTTOM 2
MLINE_RIGHT (alias) 0
MLINE_CENTER (alias) 1
MLINE_LEFT (alias) 2
dxf.flags

Use method close() and the properties start_caps and end_caps to change these flags.

Constants defined in ezdxf.lldxf.const:

dxf.flags Value
MLINE_HAS_VERTEX 1
MLINE_CLOSED 2
MLINE_SUPPRESS_START_CAPS 4
MLINE_SUPPRESS_END_CAPS 8
dxf.start_location

Start location of the reference line. (read only)

dxf.count

Count of MLINE vertices. (read only)

dxf.style_element_count

Count of elements in MLineStyle definition. (read only)

dxf.extrusion

Normal vector of the entity plane, but MLINE is not an OCS entity, all vertices of the reference line are WCS! (read only)

vertices

MLINE vertices as MLineVertex objects, stored in a regular Python list.

set_style(name: str) → None

Set MLINESTYLE by name and update geometry accordingly. The MLINESTYLE definition must exist.

set_scale_factor(value: float) → None

Set the scale factor and update geometry accordingly.

set_justification(value: int) → None

Set MLINE justification and update geometry accordingly. See dxf.justification for valid settings.

close(state: bool = True) → None

Get/set closed state of MLINE and update geometry accordingly. Compatibility interface to Polyline

__len__()

Count of MLINE vertices.

start_location() → ezdxf.math._vector.Vec3

Returns the start location of the reference line. Callback function for dxf.start_location.

get_locations() → list[Vec3]

Returns the vertices of the reference line.

extend(vertices: Iterable[Union[Sequence[float], ezdxf.math._vector.Vec2, ezdxf.math._vector.Vec3]]) → None

Append multiple vertices to the reference line.

It is possible to work with 3D vertices, but all vertices have to be in the same plane and the normal vector of this plan is stored as extrusion vector in the MLINE entity.

clear() → None

Remove all MLINE vertices.

update_geometry() → None

Regenerate the MLINE geometry based on current settings.

generate_geometry(vertices: list[Vec3]) → None

Regenerate the MLINE geometry for new reference line defined by vertices.

transform(m: Matrix44) → DXFGraphic

Transform MLINE entity by transformation matrix m inplace.

virtual_entities() → Iterator[ezdxf.entities.dxfgfx.DXFGraphic]

Yields virtual DXF primitives of the MLINE entity as LINE, ARC and HATCH entities.

These entities are located at the original positions, but are not stored in the entity database, have no handle and are not assigned to any layout.

explode(target_layout: Optional[BaseLayout] = None) → EntityQuery

Explode the MLINE entity as LINE, ARC and HATCH entities into target layout, if target layout is None, the target layout is the layout of the MLINE. This method destroys the source entity.

Returns an EntityQuery container referencing all DXF primitives.

Parameters:target_layout – target layout for DXF primitives, None for same layout as source entity.
class ezdxf.entities.MLineVertex
location

Reference line vertex location.

line_direction

Reference line direction.

miter_direction
line_params

The line parameterization is a list of float values. The list may contain zero or more items.

The first value (miter-offset) is the distance from the vertex location along the miter_direction vector to the point where the line element’s path intersects the miter vector.

The next value (line-start-offset) is the distance along the line_direction from the miter/line path intersection point to the actual start of the line element.

The next value (dash-length) is the distance from the start of the line element (dash) to the first break (gap) in the line element. The successive values continue to list the start and stop points of the line element in this segment of the mline.

fill_params

The fill parameterization is also a list of float values. Similar to the line parameterization, it describes the parameterization of the fill area for this mline segment. The values are interpreted identically to the line parameters and when taken as a whole for all line elements in the mline segment, they define the boundary of the fill area for the mline segment.

class ezdxf.entities.MLineStyle

The MLineStyle stores the style properties for the MLINE entity.

dxf.name
dxf.description
dxf.flags
dxf.fill_color

AutoCAD Color Index (ACI) value of the fill color

dxf.start_angle
dxf.end_angle
elements

MLineStyleElements object

update_all()

Update all MLINE entities using this MLINESTYLE.

The update is required if elements were added or removed or the offset of any element was changed.

class ezdxf.entities.mline.MLineStyleElements
elements

List of MLineStyleElement objects, one for each line element.

MLineStyleElements.__len__()
MLineStyleElements.__getitem__(item)
MLineStyleElements.append(offset: float, color: int = 0, linetype: str = 'BYLAYER') → None

Append a new line element.

Parameters:
  • offset – normal offset from the reference line: if justification is MLINE_ZERO, positive values are above and negative values are below the reference line.
  • colorAutoCAD Color Index (ACI) value
  • linetype – linetype name
class ezdxf.entities.mline.MLineStyleElement

Named tuple to store properties of a line element.

offset

Normal offset from the reference line: if justification is MLINE_ZERO, positive values are above and negative values are below the reference line.

color

AutoCAD Color Index (ACI) value

linetype

Linetype name