Show / Hide Table of Contents

Class MText

Represents a multiline text EntityObject.

Inheritance
System.Object
DxfObject
EntityObject
MText
Implements
IHasXData
System.ICloneable
Inherited Members
EntityObject.LayerChanged
EntityObject.OnLayerChangedEvent(Layer, Layer)
EntityObject.LinetypeChanged
EntityObject.OnLinetypeChangedEvent(Linetype, Linetype)
EntityObject.XDataAddAppReg
EntityObject.OnXDataAddAppRegEvent(ApplicationRegistry)
EntityObject.XDataRemoveAppReg
EntityObject.OnXDataRemoveAppRegEvent(ApplicationRegistry)
EntityObject.Reactors
EntityObject.Type
EntityObject.Color
EntityObject.Layer
EntityObject.Linetype
EntityObject.Lineweight
EntityObject.Transparency
EntityObject.LinetypeScale
EntityObject.IsVisible
EntityObject.Normal
EntityObject.Owner
EntityObject.XData
EntityObject.TransformBy(Matrix4)
EntityObject.ToString()
DxfObject.CodeName
DxfObject.Handle
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: netDxf.Entities
Assembly: CADability.dll
Syntax
public class MText : EntityObject, IHasXData, ICloneable
Remarks

Formatting codes for MText, you can use them directly while setting the text value or use the Write() and EndParagraph() methods.
\L Start underline
\l Stop underline
\O Start overstrike
\o Stop overstrike
\K Start strike-through
\k Stop strike-through
\P New paragraph (new line)
\pxi Control codes for bullets, numbered paragraphs and columns
\X Paragraph wrap on the dimension line (only in dimensions)
\Q Slanting (obliquing) text by angle - e.g. \Q30;
\H Text height - e.g. \H3x;
\W Text width - e.g. \W0.8x;
\F Font selection

e.g. \Fgdt;o - GDT-tolerance
e.g. \Fkroeger|b0|i0|c238|p10; - font Kroeger, non-bold, non-italic, code page 238, pitch 10

\S Stacking, fractions

e.g. \SA^B;
A
B
e.g. \SX/Y
X
-
Y
e.g. \S1#4;
1/4

\A Alignment
\A0; = bottom
\A1; = center
\A2; = top

\C Color change
\C1; = red
\C2; = yellow
\C3; = green
\C4; = cyan
\C5; = blue
\C6; = magenta
\C7; = white

\T Tracking, char.spacing - e.g. \T2;
~ Non-wrapping space, hard space
{} Braces - define the text area influenced by the code
\ Escape character - e.g. \ = "", { = "{"

Codes and braces can be nested up to 8 levels deep.

Constructors

| Improve this Doc View Source

MText()

Initializes a new instance of the MText class.

Declaration
public MText()
| Improve this Doc View Source

MText(Vector2, Double)

Initializes a new instance of the MText class.

Declaration
public MText(Vector2 position, double height)
Parameters
Type Name Description
Vector2 position

Text Vector2 in world coordinates.

System.Double height

Text height.

| Improve this Doc View Source

MText(Vector2, Double, Double)

Initializes a new instance of the MText class.

Declaration
public MText(Vector2 position, double height, double rectangleWidth)
Parameters
Type Name Description
Vector2 position

Text Vector2 in world coordinates.

System.Double height

Text height.

System.Double rectangleWidth

Reference rectangle width.

| Improve this Doc View Source

MText(Vector2, Double, Double, TextStyle)

Initializes a new instance of the MText class.

Declaration
public MText(Vector2 position, double height, double rectangleWidth, TextStyle style)
Parameters
Type Name Description
Vector2 position

Text Vector2 in world coordinates.

System.Double height

Text height.

System.Double rectangleWidth

Reference rectangle width.

TextStyle style

Text TextStyle.

| Improve this Doc View Source

MText(Vector3, Double)

Initializes a new instance of the MText class.

Declaration
public MText(Vector3 position, double height)
Parameters
Type Name Description
Vector3 position

Text Vector2 in world coordinates.

System.Double height

Text height.

| Improve this Doc View Source

MText(Vector3, Double, Double)

Initializes a new instance of the MText class.

Declaration
public MText(Vector3 position, double height, double rectangleWidth)
Parameters
Type Name Description
Vector3 position

Text Vector2 in world coordinates.

System.Double height

Text height.

System.Double rectangleWidth

Reference rectangle width.

| Improve this Doc View Source

MText(Vector3, Double, Double, TextStyle)

Initializes a new instance of the MText class.

Declaration
public MText(Vector3 position, double height, double rectangleWidth, TextStyle style)
Parameters
Type Name Description
Vector3 position

Text Vector2 in world coordinates.

System.Double height

Text height.

System.Double rectangleWidth

Reference rectangle width.

TextStyle style

Text TextStyle.

| Improve this Doc View Source

MText(String)

Initializes a new instance of the MText class.

Declaration
public MText(string text)
Parameters
Type Name Description
System.String text

Text string.

| Improve this Doc View Source

MText(String, Vector2, Double)

Initializes a new instance of the MText class.

Declaration
public MText(string text, Vector2 position, double height)
Parameters
Type Name Description
System.String text

Text string.

Vector2 position

Text Vector2 in world coordinates.

System.Double height

Text height.

| Improve this Doc View Source

MText(String, Vector2, Double, Double)

Initializes a new instance of the MText class.

Declaration
public MText(string text, Vector2 position, double height, double rectangleWidth)
Parameters
Type Name Description
System.String text

Text string.

Vector2 position

Text Vector2 in world coordinates.

System.Double height

Text height.

System.Double rectangleWidth

Reference rectangle width.

| Improve this Doc View Source

MText(String, Vector2, Double, Double, TextStyle)

Initializes a new instance of the MText class.

Declaration
public MText(string text, Vector2 position, double height, double rectangleWidth, TextStyle style)
Parameters
Type Name Description
System.String text

Text string.

Vector2 position

Text Vector2 in world coordinates.

System.Double height

Text height.

System.Double rectangleWidth

Reference rectangle width.

TextStyle style

Text TextStyle.

| Improve this Doc View Source

MText(String, Vector3, Double)

Initializes a new instance of the MText class.

Declaration
public MText(string text, Vector3 position, double height)
Parameters
Type Name Description
System.String text

Text string.

Vector3 position

Text Vector2 in world coordinates.

System.Double height

Text height.

| Improve this Doc View Source

MText(String, Vector3, Double, Double)

Initializes a new instance of the MText class.

Declaration
public MText(string text, Vector3 position, double height, double rectangleWidth)
Parameters
Type Name Description
System.String text

Text string.

Vector3 position

Text Vector2 in world coordinates.

System.Double height

Text height.

System.Double rectangleWidth

Reference rectangle width.

| Improve this Doc View Source

MText(String, Vector3, Double, Double, TextStyle)

Initializes a new instance of the MText class.

Declaration
public MText(string text, Vector3 position, double height, double rectangleWidth, TextStyle style)
Parameters
Type Name Description
System.String text

Text string.

Vector3 position

Text Vector2 in world coordinates.

System.Double height

Text height.

System.Double rectangleWidth

Reference rectangle width.

TextStyle style

Text TextStyle.

Properties

| Improve this Doc View Source

AttachmentPoint

Gets or sets the text MTextAttachmentPoint.

Declaration
public MTextAttachmentPoint AttachmentPoint { get; set; }
Property Value
Type Description
MTextAttachmentPoint
| Improve this Doc View Source

DefaultMirrText

Gets or sets if the text will be mirrored when a symmetry is performed, when the current MText entity does not belong to a DXF document.

Declaration
public static bool DefaultMirrText { get; set; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

DrawingDirection

Get or sets the MTextDrawingDirection.

Declaration
public MTextDrawingDirection DrawingDirection { get; set; }
Property Value
Type Description
MTextDrawingDirection
| Improve this Doc View Source

Height

Gets or sets the text height.

Declaration
public double Height { get; set; }
Property Value
Type Description
System.Double
| Improve this Doc View Source

LineSpacingFactor

Gets or sets the line spacing factor.

Declaration
public double LineSpacingFactor { get; set; }
Property Value
Type Description
System.Double
Remarks

Percentage of default line spacing to be applied. Valid values range from 0.25 to 4.0, the default value 1.0.

| Improve this Doc View Source

LineSpacingStyle

Get or sets the MTextLineSpacingStyle.

Declaration
public MTextLineSpacingStyle LineSpacingStyle { get; set; }
Property Value
Type Description
MTextLineSpacingStyle
| Improve this Doc View Source

Position

Gets or sets the Text Vector3 in world coordinates.

Declaration
public Vector3 Position { get; set; }
Property Value
Type Description
Vector3
| Improve this Doc View Source

RectangleWidth

Gets or sets the text reference rectangle width.

Declaration
public double RectangleWidth { get; set; }
Property Value
Type Description
System.Double
Remarks

This value defines the width of the box where the text will fit.
If a paragraph width is longer than the rectangle width it will be broken in several lines, using the word spaces as breaking points.
If you specify a width of 0, word wrap is turned off and the width of the multiline text object is as wide as the longest line of text.

| Improve this Doc View Source

Rotation

Gets or sets the text rotation in degrees.

Declaration
public double Rotation { get; set; }
Property Value
Type Description
System.Double
| Improve this Doc View Source

Style

Gets or sets the TextStyle.

Declaration
public TextStyle Style { get; set; }
Property Value
Type Description
TextStyle
| Improve this Doc View Source

Value

Gets or sets the raw text string.

Declaration
public string Value { get; set; }
Property Value
Type Description
System.String

Methods

| Improve this Doc View Source

Clone()

Creates a new MText that is a copy of the current instance.

Declaration
public override object Clone()
Returns
Type Description
System.Object

A new MText that is a copy of this instance.

Overrides
EntityObject.Clone()
| Improve this Doc View Source

EndParagraph()

Ends the current paragraph.

Declaration
public void EndParagraph()
| Improve this Doc View Source

OnTextStyleChangedEvent(TextStyle, TextStyle)

Declaration
protected virtual TextStyle OnTextStyleChangedEvent(TextStyle oldTextStyle, TextStyle newTextStyle)
Parameters
Type Name Description
TextStyle oldTextStyle
TextStyle newTextStyle
Returns
Type Description
TextStyle
| Improve this Doc View Source

PlainText()

Obtains the MText text value without the formatting codes, control characters like tab '\t' will be preserved in the result, the new paragraph command "\P" will be converted to new line feed '\r\n'.

Declaration
public string PlainText()
Returns
Type Description
System.String

MText text value without the formatting codes.

| Improve this Doc View Source

StartParagraph()

Starts a new paragraph.

Declaration
public void StartParagraph()
Remarks

When no paragraph options are used, strictly speaking, there is no need to call this method, the previous paragraph options will be inherited.
When there is no need to change the paragraph options from the previous, it is no necessary to pass again the same instance, the paragraph characteristics are inherited from the previous one. This way no codes needs to be written and it will save some characters in the final string.

| Improve this Doc View Source

StartParagraph(MTextParagraphOptions)

Starts a new paragraph.

Declaration
public void StartParagraph(MTextParagraphOptions options)
Parameters
Type Name Description
MTextParagraphOptions options

Paragraph options.

Remarks

When no paragraph options are used, strictly speaking, there is no need to call this method, the previous paragraph options will be inherited.
When there is no need to change the paragraph options from the previous, it is no necessary to pass again the same instance, the paragraph characteristics are inherited from the previous one. This way no codes needs to be written and it will save some characters in the final string.

| Improve this Doc View Source

TransformBy(Matrix3, Vector3)

Moves, scales, and/or rotates the current entity given a 3x3 transformation matrix and a translation vector.

Declaration
public override void TransformBy(Matrix3 transformation, Vector3 translation)
Parameters
Type Name Description
Matrix3 transformation

Transformation matrix.

Vector3 translation

Translation vector.

Overrides
EntityObject.TransformBy(Matrix3, Vector3)
Remarks

Non-uniform scaling is not supported, it would require to decompose each line into independent Text entities. When the current Text entity does not belong to a DXF document, the text will use the DefaultMirrText when a symmetry is performed; otherwise, the drawing variable MirrText will be used.
Matrix3 adopts the convention of using column vectors to represent a transformation matrix.

| Improve this Doc View Source

Write(String)

Adds the text to the current paragraph.

Declaration
public void Write(string txt)
Parameters
Type Name Description
System.String txt

Text string.

| Improve this Doc View Source

Write(String, MTextFormattingOptions)

Adds the text to the current paragraph.

Declaration
public void Write(string txt, MTextFormattingOptions options)
Parameters
Type Name Description
System.String txt

Text string.

MTextFormattingOptions options

Text formatting options.

| Improve this Doc View Source

WriteFraction(String, String, FractionFormatType)

Formats a text string to represent a fraction.

Declaration
public void WriteFraction(string numerator, string denominator, FractionFormatType fractionType)
Parameters
Type Name Description
System.String numerator

Fraction numerator.

System.String denominator

Fraction denominator.

FractionFormatType fractionType

Style of the fraction.

Remarks

In fractions the characters '/' and '#' are reserved if you need to write them you must write "/" and "#", respectively.

| Improve this Doc View Source

WriteFraction(String, String, FractionFormatType, MTextFormattingOptions)

Formats a text string to represent a fraction.

Declaration
public void WriteFraction(string numerator, string denominator, FractionFormatType fractionType, MTextFormattingOptions options)
Parameters
Type Name Description
System.String numerator

Fraction numerator.

System.String denominator

Fraction denominator.

FractionFormatType fractionType

Style of the fraction.

MTextFormattingOptions options

Text formatting options.

Remarks

In fractions the characters '/' and '#' are reserved if you need to write them you must write "/" and "#", respectively.
Do not combine fractions with super or subscript options, it is not supported (stacking commands cannot be nested).

Events

| Improve this Doc View Source

TextStyleChanged

Declaration
public event MText.TextStyleChangedEventHandler TextStyleChanged
Event Type
Type Description
MText.TextStyleChangedEventHandler

Implements

IHasXData
System.ICloneable
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX