Table of Contents

Class DxfMlineBuilder

Namespace
GeometryHelper.Dxf
Assembly
GeometryHelper.dll

Builds an MLINE as AutoCAD writes it, from the points it is drawn through, its style, scale and justification, and builds the record anew after an edit, as AutoCAD's Mline (AppendSegment, MoveVertexAt, IsClosed) does: its direction, miter and the offset of each element at every vertex worked out as AutoCAD works them out. A multiline is a DxfUnknownEntity whose DxfName is MLINE.

public sealed class DxfMlineBuilder
Inheritance
DxfMlineBuilder
Inherited Members

Remarks

A multiline of the style STANDARD (two elements 0.5 either side of the line) at scale 1, justified at its top, through (0, 0), (100, 0) and (100, 100), is written as AutoCAD writes it: the style's name (2) and handle (340), scale (40), justification (70: 0 top, 1 zero, 2 bottom), flags (71: 1, plus 2 closed, 4 start caps left off, 8 end caps left off), vertex count (72), element count (73), the first vertex (10) and the normal (210); then at each vertex its point (11), the direction of the segment it starts (12; the last vertex has that of the segment before it), its unit miter (13) and for each element the count (74) and parameters (41) and 75 of 0. At the corner (100, 0) the miter is (-0.7071, 0.7071), the half angle's cosine 0.7071, and the elements' first parameters 0 and -1.4142 (the offset of the element from the top, 0 and -1, divided by the cosine); the straight vertices give 0 and -1. At scale 20 and justified at its middle they are 10 and -10, and justified at its bottom 20 and 0.

The miter of an inner vertex is the bisector of the normals of the two segments, that of an open start the direction turned by the style's start angle, that of an end the direction of its last segment turned by the end angle; the cosine in the division is the miter's against the normal of the segment, never less than 1E-4 in magnitude, as AutoCAD's. After the first parameter of an element come the stretches it is drawn along the segment, a start and a stop by turns, measured from where the element stands at the vertex: a start of nought and no stop is the whole segment, as a multiline is written, and the cuts of MLEDIT are the gaps between a stop and the next start. These are read from an existing multiline and written back with it, so that Rebuild(DxfUnknownEntity) after a point is moved leaves the cuts of the segments that stay where they were.

Constructors

DxfMlineBuilder(DxfMlineStyle)

Initializes a builder of a multiline of a style, as AutoCAD's new Mline() with its Style set: scale 1, justified at its top, open, the normal (0, 0, 1), with no points yet.

DxfMlineBuilder(DxfUnknownEntity)

Initializes a builder from a multiline of a drawing: its style, scale, justification, flags, normal and points, and the stretches of its elements, as its record holds them.

Properties

IsClosed

Gets or sets whether the multiline closes on its first point (flag 2 of group 71), as AutoCAD's IsClosed; it takes three points or more.

Justification

Gets or sets which line of the multiline stands on the points (group 70), as AutoCAD's Justification; top for a new one.

Normal

Gets or sets the normal of the plane the multiline lies in (210, 220, 230), as AutoCAD's Normal; (0, 0, 1) for a new one. The elements stand to the left of a segment, which is the normal crossed with the segment's direction.

Points

Gets the points the multiline passes through, in order, as AutoCAD's AppendSegment adds them and MoveVertexAt moves them; edit the list, then Build() or Rebuild(DxfUnknownEntity). The stretches of the elements read from an MLINE stay with the points while their number is the same.

Scale

Gets or sets the scale (group 40), as AutoCAD's Scale: the offsets of the style are multiplied by it, so that STANDARD, 1 wide, is 20 wide at 20. Nought and a negative scale are taken, as AutoCAD takes them (the elements stand on the other side with a negative one).

Style

Gets or sets the style the multiline is drawn by, as AutoCAD's Style: its name and handle are written into the record, its elements and angles decide the offsets.

SuppressEndCaps

Gets or sets whether the caps of the style are left off the end (flag 8), as AutoCAD's SupressEndCaps.

SuppressStartCaps

Gets or sets whether the caps of the style are left off the start (flag 4), as AutoCAD's SupressStartCaps.

Methods

Build()

Writes a new MLINE of the style, scale, justification, flags and points, as AutoCAD writes one, not yet in a drawing: AppendEntity it to a block. Its layer, colour and linetype are the entity's own, given as for any entity.

MoveVertexAt(int, GeoPoint3)

Moves the point at an index, as AutoCAD's MoveVertexAt moves it (a grip dragged, a vertex stretched): a segment that keeps its way keeps the cuts of its elements where they were along it, and one that turns is drawn whole again. A multiline through (0, 0), (100, 0) and (100, 100) at scale 20, its second segment cut from 30 to 60, whose vertex (100, 0) goes to (100, -10), keeps that cut at 40 to 70 from the moved vertex, where it was; its first segment, which turns, is whole. A stretch that starts at the vertex stays there, and none goes below nought. A cut across a vertex leaves the next segment's list empty or starting after nought (a multiline of 100 by 100 cut from (50, 0) to (100, 50) has (100, 0) hold 50 for its first element), which AutoCAD reads as going on from the segment before. Where the segment before is made whole by the move and was not, the list gains a nought in front (the vertex (100, 0) moved to (100, -10) holds 0 and 60), shifted by the way the vertex moved and not the element's start, and the end of the multiline is left with nothing past its last vertex; a segment that turns keeps such a list as it was. A closed multiline is moved the same way, its first segment following its last: the square of 100 closed, cut from (100, 50) to (50, 100) across (100, 100), whose vertex (100, 100) goes to (90, 90), holds 0 and 50 there for its first element where it held 50. The lists of the first segment and the last of a closed multiline, which join the end of its points to their start, get no nought: the triangle (0, 0), (100, 0), (50, 80) cut across (50, 80), whose vertex (100, 0) goes to (90, 0), still holds 47.1699 there for its first element; but an empty list of the last segment (a cut that goes across it from the segment before) gets its nought when the move makes the segment before whole (the square of 100 cut from (15, 0) to (15, 100), whose vertex (100, 100) goes to (108, 91), holds 0 for both elements at (0, 100) where it held none). A stop that comes to lie at or past the end of a segment of a closed multiline is left out, whether its list is odd or even (the six-sided staircase (0, 0), (100, 0), (100, 50), (50, 50), (50, 100), (0, 100) cut from (75, 50) to (50, 92), whose vertex (50, 100) goes to (50, 90), holds no stretch for the first element at (50, 50) where it held 42). A closed multiline whose move shortens a segment until a cut that reaches its end starts at the end leaves that stop out (the six-sided staircase (0, 0), (100, 0), (100, 50), (50, 50), (50, 100), (0, 100) cut across (0, 0) from (0, 10) to (10, 0), with (0, 0) moved to (0, 10), holds 0 and no longer 0 and 90 on its last segment), and the list that goes on across the next vertex gets its nought; a move that carries the start of a cut that goes on across a vertex back past the start of its segment leaves that list at nought, not below it and not nought twice.

Rebuild(DxfUnknownEntity)

Writes the record of an MLINE anew from the points, style, scale, justification and flags, as AutoCAD rewrites it when a vertex is moved: its head and every vertex, the layer, colour, linetype and extended data kept.