Class DxfMText
- Namespace
- GeometryHelper.Dxf
- Assembly
- GeometryHelper.dll
An MTEXT of a DXF file, as AutoCAD's MText: words of several lines with their formatting, held at
Location by its Attachment, TextHeight high, wrapping at Width,
reading along Direction in the plane of its Normal.
public sealed class DxfMText : DxfEntity
- Inheritance
-
DxfMText
- Inherited Members
Remarks
An MTEXT of Contents {\fArial|b1;Bold}\PLine two at (5, 5, 0), 2.5 high and 40 wide, turned by
30 degrees, reads as Text "Bold" and "Line two" on two lines, Rotation 0.5236 radians and
Direction (0.866, 0.5, 0). Its location and direction are in world coordinates, as the file writes them.
A property set writes its groups as DxfWriter writes a number, every other group of the record kept as
it was; a property given the value it has changes nothing. A file of R12 has no MTEXT: one made in code, new
DxfMText { Contents = "B-12\\PM16", Location = new GeoPoint3(10, 20, 0) }, is written there by
AppendEntity(DxfEntity) as one TEXT for each of its paragraphs, B-12 and M16, its
formatting left out as Text leaves it out; the lines are not wrapped at its width, as AutoCAD's SAVEAS to
R12 wraps them by the letters of the font, which the library does not read. The MTEXT itself stays in no file. GetGeometry() gives the DxfText DxfReader reads of it.
Before R2018 an MTEXT's columns after its first are MTEXTs of their own, which it links to by handle in its extended
data (ACAD_MTEXT_COLUMNS). It is one text to AutoCAD and ezdxf: moved by
TransformBy(GeoTransform3) or its Location, Rotation,
Direction or Normal, it moves them with it;
given a TextHeight or Height, it gives them the same; erased, it takes them with it. Its
Contents holds the words of its first column alone. A copy of it (Clone(),
GetTransformedCopy(GeoTransform3), an INSERT's Explode()) holds the
words of them all itself, after a column break \N each for static columns, and links to none of them, so that no
two MTEXTs claim the same columns: three static columns one, two and three come out as one\Ntwo\Nthree.
Constructors
- DxfMText()
Initializes an MTEXT with no words at the origin, 2.5 high, held at its top left, as AutoCAD's
new MText(), on layer 0 in the text style Standard, in no file; give it its words and place before it is drawn.
Properties
- ActualHeight
Gets the height the MTEXT's words take, as AutoCAD's
ActualHeight: where ActualWidth measures them, from the top of the first line to the foot of the last, as AutoCAD 2021 lays them out (checks F1a and F4): a line of one height from the lower of its baseline and the bottom of its ink up to the higher of the height of its letters and the top of its ink, a line drawn under them a fifth of their height below the baseline and over them a fifth above their height: "ABC" of txt.shx 4 high is 4 high, and "g" 5.333. With its line spacing at least (group 73 of 1), the top of each line is the factor (44) times the top of the line before, a third of that line's height and a third of the MTEXT's TextHeight below the top of the line before it, so that "ABC\PDE" 4 high is 10.667 high and "ABC\P{\H3x;ABC}\PDEF" 28; spaced exactly (2), the MTEXT is its height, the spacing of each line after the first and a third of its height high, whatever its letters: "ABC\PDE" 12. An empty paragraph at the end is no line: "ABC\P" is 4 high, "ABC\P\P" 10.667. Elsewhere, group 43 as the file writes it; nought where it gives none.
- ActualWidth
Gets the width the MTEXT's words take, as AutoCAD's
ActualWidth: where the drawing's FontSearchPath finds the SHX or TrueType font of its style, the width of its widest line, laid out as AutoCAD 2021 lays them out (checks F1a, F2 and F4): a line from its first ink, or its start where it starts with a space, to the ink of its last letter that is no space, the spaces after it left out, a line of spaces alone as wide as they move the pen: "ABC" of txt.shx 4 high is 10.667 wide, and " ABC" 22.667; of a TrueType font, ink left of the line's start not counted, "A" of arial.ttf 4 high 3.735 wide, from 0. The lines are its paragraphs (\P), wrapped at its Width where it has one: "The quick brown fox jumps over the lazy dog and keeps on running" of txt.shx 4 high, 41 wide, is seven lines, the widest 38. Elsewhere, group 42 as the file writes it; nought where it gives none.
- AlignChange
Gets the code that sets how the letters stand on the line, as AutoCAD's
AlignChange:\A, followed by 0, 1 or 2 for the bottom, the middle and the top and a semicolon,\A1;.
- Attachment
Gets or sets the point the MTEXT is held by (group 71), as AutoCAD's
Attachment; TopLeft where the record gives none. An annotative MTEXT's is that of the context it is read at (its 70), as Location says: AutoCAD 2021 read one whose record says 1 and whose context of 1:1 says 5 as held by its middle (check D35b).
- BackgroundFill
Gets or sets whether a background is drawn behind the words (flag 1 of group 90), as AutoCAD's
BackgroundFill.
- BackgroundFillColor
Gets or sets the colour of the background (group 63, and 421 for red, green and blue, 431 for its book's name), as AutoCAD's
BackgroundFillColor; null where the record gives none.
- BackgroundScaleFactor
Gets or sets how far the background reaches past the words, against their height (group 45), as AutoCAD's
BackgroundScaleFactor; 1.5 where the record gives none, as AutoCAD gives it.
- BackgroundTransparency
Gets or sets how see-through the background of the MTEXT is (group 441), as AutoCAD's
BackgroundTransparency: written as group 440 of an entity is, 0x02000000 and the alpha for an alpha, 0x01000000 for by block; by layer where the record gives none. AutoCAD and BricsCAD keep it but draw nothing by it, as ezdxf notes.
- BlockBegin
Gets the brace that opens a group of words whose formatting ends with it, as AutoCAD's
BlockBegin:{, as in{\H2x;Big} small.
- BlockEnd
Gets the brace that closes a group of words opened by BlockBegin, as AutoCAD's
BlockEnd:}.
- ColorChange
Gets the code that sets the colour of the letters, as AutoCAD's
ColorChange:\C, followed by an AutoCAD colour index and a semicolon,\C1;for red.
- ColumnAutoHeight
Gets or sets whether the columns are all of one height, the MTEXT's Height (group 73 of its embedded object, 79 of its extended data), as AutoCAD's
ColumnAutoHeight; false where it gives none.
- ColumnCount
Gets or sets how many columns the MTEXT has (group 72 of its embedded object, 76 of its extended data), as AutoCAD's
ColumnCount: where the embedded object gives none, as for dynamic columns of auto height, worked out from the width of all the columns (42) as ezdxf works it out; nought where the MTEXT has no columns.
- ColumnFlowReversed
Gets or sets whether the columns run from right to left (group 74 of its embedded object, 78 of its extended data), as AutoCAD's
ColumnFlowReversed; false where it gives none.
- ColumnGutterWidth
Gets or sets the space between the columns (group 45 of its embedded object, 49 of its extended data), as AutoCAD's
ColumnGutterWidth; nought where it gives none.
- ColumnType
Gets or sets how the MTEXT is set in columns, as AutoCAD's
ColumnType: from its embedded object from R2018 (group 71), else from its extended data of ACAD (75), as ezdxf reads them; NoColumns where it gives none. In a file older than R2007 (AC1021), which brought columns, the extended data are columns only with the MTEXTs of the later columns they link (ACAD_MTEXT_COLUMNS), as AutoCAD and ezdxf write them: AutoCAD 2021 read three MTEXTs of R2000 given the column data alone, two static columns 50 wide among them, as of no columns, each 50 wide (Width), the one of a defined height of 15 that high (Height).
- ColumnWidth
Gets or sets how wide each column is (group 44 of its embedded object, 48 of its extended data), as AutoCAD's
ColumnWidth; nought where it gives none.
- Contents
Gets or sets the words of the MTEXT with their formatting (groups 3 and 1), as AutoCAD's
Contents: as the file writes them,\Pa new paragraph,{\H1.5x;Big}letters half as high again, but each escape of four digits read as the letter it stands for before the formatting, as AutoCAD 2021 reads it in a file of any version:a\U+0110bgives aĐb,\U+D83D\U+DE00the letter beyond U+FFFF of those two halves,\U+0041an A,\U+0110a backslash and Đ, and\U+005CPthe code of a new paragraph.\U+0000and an escape of fewer digits are kept as written. A caret and the character after it are read first, as AutoCAD reads them:a^Jbgives a, a line feed and b,a^ bgives a^b, anda^@bends at a. Empty where the record gives none. Before R2018 an MTEXT whose later columns are MTEXTs of their own holds only the words of its first: those of the others are in their MTEXTs, as AutoCAD and ezdxf keep them.
- ContentsRTF
Gets or sets the words of the MTEXT as RTF, as AutoCAD's
ContentsRTF: its Contents written as a document of RTF and read back from one, as SetContentsRtf(string) reads it.
- Direction
Gets or sets the direction the MTEXT reads along (groups 11, 21, 31), as AutoCAD's
Direction: in world coordinates, of unit length; where the record gives none, the x axis of the system of its plane turned by its angle (50); where it gives no angle either, the world's x axis put into its plane, as AutoCAD 2021 reads it (check mirror-3 GHM3A): (1, 0, 0) on the normal (0, 0, -1), whose x axis is the world's -x, and (0.8, 0, 0.6) on (0.6, 0, -0.8); the x axis of the system of its plane where the plane holds no part of the world's x axis, as on the normal (1, 0, 0). An annotative MTEXT's is that of the context it is read at (its 10, 20, 30), as Location says.
- FlowDirection
Gets or sets which way the lines follow one another (group 72), as AutoCAD's
FlowDirection; LeftToRight where the record gives none.
- FontChange
Gets the code that sets the font, as AutoCAD's
FontChange:\F, followed by the font's file and a semicolon,\Fromans.shx;; a TrueType font by its name is\f,\fArial|b1|i0;.
- GeometricExtents
Gets the box the MTEXT fills, as AutoCAD's
GeometricExtents: where ActualWidth measures its words, the box AutoCAD 2021 gives it (check F4), as wide as its Width, or its ActualWidth where it has none, and ActualHeight high, held at its Location by its Attachment, along its Direction in the plane of its Normal: "ABC\PDE" of txt.shx 4 high, 41 wide, held at its top left at (10, 20, 0), from (10, 9.333, 0) to (51, 20, 0). Elsewhere as GeometricExtents gives it.
- Height
Gets or sets the height of the box the MTEXT is given (group 46), as AutoCAD's
Height; where the record gives none, the height of its columns of one height, from its embedded object (41) or its extended data of ACAD (ACAD_MTEXT_DEFINED_HEIGHT), as ezdxf reads it; nought where it gives neither, and from R2007 for dynamic columns of their own heights, whoseACAD_MTEXT_DEFINED_HEIGHTis the first column's, as AutoCAD 2021 writes and reads it. A file older than R2007 (AC1021) has no group 46, and its height is that of the extended data whatever the columns: the MTEXT of R2000 in three static columns 30 high has the height 30, and AutoCAD 2021 read its own R2000 MTEXT in dynamic columns 15, 25 and 0 high, of the defined height 15, as 15 high (its 09-a). An annotative MTEXT's is that of the context it is read at (its 41), as its Width is.
- HeightChange
Gets the code that sets the height of the letters, as AutoCAD's
HeightChange:\H, followed by a height and a semicolon,\H3.5;, or a factor of the height with an x,\H1.5x;.
- LineBreak
Gets the code that breaks the line, as AutoCAD's
LineBreak:\P, the one break an MTEXT has, the same as ParagraphBreak.
- LineSpaceDistance
Gets or sets the distance from one line of the MTEXT to the next, as AutoCAD's
LineSpaceDistance: the LineSpacingFactor times single spacing, which is 5/3 of the TextHeight, as AutoCAD spaces lines: 5 for letters 3 high at a factor of 1.
- LineSpacingFactor
Gets or sets the spacing of the lines against that of the text style (group 44), as AutoCAD's
LineSpacingFactor; 1 where the record gives none.
- LineSpacingStyle
Gets or sets how the spacing of the lines is taken (group 73), as AutoCAD's
LineSpacingStyle; AtLeast where the record gives none.
- Location
Gets or sets where the MTEXT is held (groups 10, 20, 30), as AutoCAD's
Location: in world coordinates, as the file writes it; the origin where the record gives none. An annotative MTEXT is held where its context of the scale 1:1 says (its 11, 21, 31), else its default context, as AutoCAD 2021 reads one whatever CANNOSCALE says, and as Position reads a text: one whose record says (10, 40) and whose context of 1:1 says (14, 44) is held at (14, 44) (check D35b). Its Direction, Rotation, Width, Height and Attachment are that context's too, and its TextHeight that of its scale.
- NonBreakSpace
Gets the code of a space the line is not broken at, as AutoCAD's
NonBreakSpace:~.
- Normal
Gets or sets the normal of the plane the MTEXT stands in (groups 210, 220, 230), as AutoCAD's
Normal; of unit length, (0, 0, 1) where the record gives none.
- ObliqueChange
Gets the code that slants the letters, as AutoCAD's
ObliqueChange:\Q, followed by the angle in degrees and a semicolon,\Q15;.
- OverlineOff
Gets the code that ends a line over the letters, as AutoCAD's
OverlineOff:\o.
- OverlineOn
Gets the code that begins a line over the letters, as AutoCAD's
OverlineOn:\O.
- ParagraphBreak
Gets the code that ends a paragraph, as AutoCAD's
ParagraphBreak:\P,B-12\PM16two lines.
- Rotation
Gets or sets how far the MTEXT is turned, as AutoCAD's
Rotation: in radians from the x axis of the system of its normal's plane, from nought up to 2 pi; read from its direction (11) where it has one, which wins, else from its angle (50, in degrees), else from the direction it reads along where it has neither, as Direction says: pi on the normal (0, 0, -1), as AutoCAD 2021 reads it. An annotative MTEXT's is that of the direction of the context it is read at (its 10, 20, 30), as Location says.
- ShowBorders
Gets or sets whether a frame is drawn about the MTEXT (flag 16 of group 90), as AutoCAD's
ShowBorders: the text frame of AutoCAD 2016 on, drawn in the colour of the words, as ezdxf reads and writes it.
- StackStart
Gets the code that stacks two parts, as AutoCAD's
StackStart:\S, followed by the upper part, a^,/or#, the lower and a semicolon,\S1/2;for a half.
- StrikethroughOff
Gets the code that ends a line through the letters, as AutoCAD's
StrikethroughOff:\k.
- StrikethroughOn
Gets the code that begins a line through the letters, as AutoCAD's
StrikethroughOn:\K.
- Text
Gets the words of the MTEXT without their formatting, as AutoCAD's
Text: as DxfReader reads them, a new paragraph a line feed, a stack\S1^2;as 1/2,%%da degree sign and an escape its letter; the words of its own column only, where its later columns are MTEXTs of their own, as Contents says.
- TextHeight
Gets or sets how high the letters are (group 40), as AutoCAD's
TextHeight; 2.5 where the record gives none. An annotative MTEXT's is as high as the scale it is read at makes it (Location): its record holds the height at its default scale, so that one 2.5 high at the default 1:2 is 1.25 high at 1:1, as AutoCAD 2021 reads it.
- TextStyle
Gets or sets the text style of the MTEXT, as AutoCAD's
TextStyleIdgives its id: the record of TextStyleName in the text style table of the MTEXT's drawing; null where it has none of that name, or the MTEXT is in no drawing and was made in code.
- TextStyleName
Gets or sets the name of the text style of the MTEXT (group 7), as AutoCAD's
TextStyleName: as the style table names it, its escapes read as letters;Standardwhere the record gives none.
- TrackChange
Gets the code that sets the room between the letters, as AutoCAD's
TrackChange:\T, followed by a factor and a semicolon,\T1.2;.
- UnderlineOff
Gets the code that ends a line under the letters, as AutoCAD's
UnderlineOff:\l.
- UnderlineOn
Gets the code that begins a line under the letters, as AutoCAD's
UnderlineOn:\L.
- UseBackgroundColor
Gets or sets whether the background takes the colour of the drawing's background (flag 2 of group 90), as AutoCAD's
UseBackgroundColor.
- Width
Gets or sets the width the lines wrap at (group 41), as AutoCAD's
Width; nought, no wrapping, where the record gives none. An MTEXT in columns before R2018 (AC1032), whose 41 holds the width of a column, is as wide as all its columns with the gutters between them, as AutoCAD 2021 reads it: two static columns 50 wide with a gutter of 10 in R2007 or R2000 make an MTEXT 110 wide, thirteen dynamic ones 770, and one 50, though AutoCAD writes 41 50 on each. An annotative MTEXT is as wide as the context it is read at says (its 40), at that scale, not as its record says (Location): AutoCAD 2021 read one whose record says 40 and whose context of 1:1 says 30 as 30 wide, whatever its default (check D35b).
- WidthChange
Gets the code that widens the letters, as AutoCAD's
WidthChange:\W, followed by a factor and a semicolon,\W0.8;.
Methods
- ConvertFieldToText()
Makes the MTEXT's fields words, as AutoCAD's
ConvertFieldToText: the field of its words taken out with its children, as RemoveField() takes it out, and its Contents (3 and 1) kept as they are, the values AutoCAD last gave the fields among them. Nothing where it has no field.
- Erase()
Erases the MTEXT, as AutoCAD's
Erasedoes, as Erase() says; an MTEXT whose later columns are MTEXTs of their own (ACAD_MTEXT_COLUMNS, before R2018) takes them with it, as AutoCAD erases one text.
- Explode()
Gets the texts the MTEXT breaks into, as AutoCAD's
Explodedoes: one TEXT for each paragraph (\P, a column break\Ntaken as one), its formatting and the heights of its codes left out as Text leaves them out, as an MTEXT is written into a drawing of R12 (see AppendEntity(DxfEntity)): each in its text style, its height, turn and plane, the lines spaced as LineSpaceDistance says. B-12 and M16 on two lines, 2.5 high, held at the top left at (10, 20), come out as two TEXTs on the baselines 17.5 and 13.33 high. Where the drawing's FontSearchPath measures its words (ActualWidth), as AutoCAD 2021 explodes it (check F4): a TEXT for each run of letters of one look of each line as the font lays them out, wrapped at its Width, held at its left where the pen stands at the run, the ink of the line at the left of its place in the box (or centred on, or ending at, the Location for an MTEXT held at its centre or right), each its height and width factor, a line under, over or through it written%%U,%%Oor%%K: "A\H2x;B\H0.5x;C\PDEF" of txt.shx 4 high held at the top left at (10, 20) comes out as A at (10, 12), B 8 high at (14, 12), C at (22, 12) and DEF at (10, 4). A colour within the words is not given to its TEXT. A stack (the words1over2inA\S1/2;B) is the TEXT of its numerator, a LINE for its bar or slash, and the TEXT of its denominator, each as high as the letters of the stack, where the fonts measure the words (see GeometryHelper.Dxf.DxfStackShape): txt.shx 0.18 high held at the top left at (10, 10) gives A at (10, 9.58), the 1 at (10.21, 9.82), the bar from (10.18, 9.79) to (10.3, 9.79), the 2 at (10.18, 9.58) and B at (10.36, 9.58); a stack with a line under, over or through it, or in a TrueType font, is left as the TEXT of its words.
- GetColumnHeight(int)
Gets the height of a column (the groups 46 of its embedded object, the 1040 after a 50 of its extended data), as AutoCAD's
GetColumnHeight: for columns of their own heights; nought for one the MTEXT gives no height.
- GetMTextWithFieldCodes()
Gets the words of the MTEXT with the codes of its fields in their places, as AutoCAD's
getMTextWithFieldCodes: the code of its field (GetField()), its formatting codes with it, each field it holds standing as its code in its markers, at every depth. The MTEXT{\H1.5x;Length} 2400 mm, the length a field, gives{\H1.5x;Length} %<\AcObjProp Object(%<_ObjIdx 0>%).Length \f "%lu2">% mm, the object named by its index among the field's objects (331) as the file holds it; one with no field gives its Contents.
- SetAttachmentMovingLocation(DxfAttachmentPoint)
Holds the MTEXT by another of its points where it stands, as AutoCAD's
SetAttachmentMovingLocation: its Attachment set and its Location moved to that point of its box, so that the words stay where they are. The box is as wide as the group 41 (Width, but a column's before R2018 for an MTEXT in columns), the ActualWidth where the MTEXT does not wrap, and ActualHeight high, as the file writes them, along its Direction and up from it in its plane: the MTEXT 40 wide held at its top left at (20, 40, 0), held at its top centre, stands at (40, 40, 0). An annotative MTEXT's box is as wide as the context it is read at says (Width), and its location and attachment are written as Location and Attachment write them, as AutoCAD 2021 writes them: the MTEXT read at (14, 44) at 1:1, 30 wide and held by its middle, held by its middle left, stands at (1.01, 36.5), its context of 1:2 left as it was (check D35c).
- SetColumnHeight(int, double)
Sets the height of a column of dynamic columns of their own heights, as AutoCAD's
SetColumnHeight: the 46 of its place in the embedded object from R2018, the 1040 of its place after the 50 of the extended data of ACAD before. Columns of one height take the MTEXT's Height instead.
- SetContentsRtf(string)
Sets the words of the MTEXT from a document of RTF, as AutoCAD's
SetContentsRtf: its words, with the codes of an MTEXT for what it sets that an MTEXT has, each written where the words take it on or off.
- SetDynamicColumns(double, double, bool)
Sets the MTEXT in dynamic columns, as AutoCAD's
SetDynamicColumns: columns as wide as given, a gutter between them, which AutoCAD fills with the words as they flow; all as high as the MTEXT's Height where their height is automatic, else each of its own, given the MTEXT's Height to start with and set by SetColumnHeight(int, double). The count of columns is kept, 1 where the MTEXT had none; written as ColumnType says, the MTEXT's Width made to agree, as SetStaticColumns(double, double, int) makes it: that of the columns the MTEXT counts, as AutoCAD counts those the words fill only as it lays them out.
- SetStaticColumns(double, double, int)
Sets the MTEXT in static columns, as AutoCAD's
SetStaticColumns: as many columns as given, each as wide as given and as high as the MTEXT's Height, a gutter between them; written as ColumnType says, the MTEXT's group 41 (and 40 of its embedded object) made the width of all the columns with their gutters from R2018, and a column's before it, as AutoCAD 2021 writes it: two columns 50 wide with a gutter of 10 give an MTEXT of R2018 41 110, and one of R2007 or R2000 41 50, each read as 110 wide (Width). Three columns 12.5 wide with gutters of 2.5 take 42.5 across.