@@ -18,25 +18,49 @@ namespace ACadSharp.Entities
1818 public partial class MText : Entity , IText
1919 {
2020 /// <inheritdoc/>
21- public override ObjectType ObjectType => ObjectType . MTEXT ;
21+ [ DxfCodeValue ( 11 , 21 , 31 ) ]
22+ public XYZ AlignmentPoint { get ; set ; } = XYZ . AxisX ;
2223
23- /// <inheritdoc/>
24- public override string ObjectName => DxfFileToken . EntityMText ;
24+ /// <summary>
25+ /// Attachment point
26+ /// </summary>
27+ [ DxfCodeValue ( 71 ) ]
28+ public AttachmentPointType AttachmentPoint { get ; set ; } = AttachmentPointType . TopLeft ;
2529
26- /// <inheritdoc/>
27- public override string SubclassMarker => DxfSubclassMarker . MText ;
30+ /// <summary>
31+ /// Background fill color
32+ /// </summary>
33+ /// <remarks>
34+ /// Color to use for background fill when group code 90 is 1.
35+ /// </remarks>
36+ [ DxfCodeValue ( 63 , 420 , 430 ) ]
37+ public Color BackgroundColor { get ; set ; }
2838
2939 /// <summary>
30- /// A 3D WCS coordinate representing the insertion or origin point.
40+ /// Background fill setting
3141 /// </summary>
32- [ DxfCodeValue ( 10 , 20 , 30 ) ]
33- public XYZ InsertPoint { get ; set ; } = XYZ . Zero ;
42+ [ DxfCodeValue ( 90 ) ]
43+ public BackgroundFillFlags BackgroundFillFlags { get ; set ; } = BackgroundFillFlags . None ;
3444
3545 /// <summary>
36- /// Specifies the three-dimensional normal unit vector for the object .
46+ /// Determines how much border there is around the text .
3747 /// </summary>
38- [ DxfCodeValue ( 210 , 220 , 230 ) ]
39- public XYZ Normal { get ; set ; } = XYZ . AxisZ ;
48+ [ DxfCodeValue ( 45 ) ]
49+ public double BackgroundScale { get ; set ; } = 1.5 ;
50+
51+ /// <summary>
52+ /// Transparency of background fill color
53+ /// </summary>
54+ [ DxfCodeValue ( 441 ) ]
55+ public Transparency BackgroundTransparency { get ; set ; }
56+
57+ public TextColumn Column { get ; set ; } = new TextColumn ( ) ;
58+
59+ /// <summary>
60+ /// Drawing direction
61+ /// </summary>
62+ [ DxfCodeValue ( 72 ) ]
63+ public DrawingDirectionType DrawingDirection { get ; set ; } = DrawingDirectionType . LeftToRight ;
4064
4165 /// <inheritdoc/>
4266 [ DxfCodeValue ( 40 ) ]
@@ -53,10 +77,49 @@ public double Height
5377 }
5478
5579 /// <summary>
56- /// Reference rectangle width.
80+ /// Horizontal width of the characters that make up the mtext entity.
81+ /// This value will always be equal to or less than the value of group code 41
5782 /// </summary>
58- [ DxfCodeValue ( 41 ) ]
59- public double RectangleWidth { get ; set ; }
83+ /// <remarks>
84+ /// read-only, ignored if supplied
85+ /// </remarks>
86+ [ DxfCodeValue ( DxfReferenceType . Ignored , 42 ) ]
87+ public double HorizontalWidth { get ; set ; } = 0.9 ;
88+
89+ /// <summary>
90+ /// A 3D WCS coordinate representing the insertion or origin point.
91+ /// </summary>
92+ [ DxfCodeValue ( 10 , 20 , 30 ) ]
93+ public XYZ InsertPoint { get ; set ; } = XYZ . Zero ;
94+
95+ public bool IsAnnotative { get ; set ; } = false ;
96+
97+ /// <summary>
98+ /// Mtext line spacing factor.
99+ /// </summary>
100+ /// <remarks>
101+ /// Percentage of default (3-on-5) line spacing to be applied.Valid values range from 0.25 to 4.00
102+ /// </remarks>
103+ [ DxfCodeValue ( 44 ) ]
104+ public double LineSpacing { get ; set ; } = 1.0 ;
105+
106+ /// <summary>
107+ /// Mtext line spacing style.
108+ /// </summary>
109+ [ DxfCodeValue ( 73 ) ]
110+ public LineSpacingStyleType LineSpacingStyle { get ; set ; }
111+
112+ /// <summary>
113+ /// Specifies the three-dimensional normal unit vector for the object.
114+ /// </summary>
115+ [ DxfCodeValue ( 210 , 220 , 230 ) ]
116+ public XYZ Normal { get ; set ; } = XYZ . AxisZ ;
117+
118+ /// <inheritdoc/>
119+ public override string ObjectName => DxfFileToken . EntityMText ;
120+
121+ /// <inheritdoc/>
122+ public override ObjectType ObjectType => ObjectType . MTEXT ;
60123
61124 /// <summary>
62125 /// Reference rectangle height.
@@ -65,20 +128,28 @@ public double Height
65128 public double RectangleHeight { get ; set ; }
66129
67130 /// <summary>
68- /// Attachment point
131+ /// Reference rectangle width.
69132 /// </summary>
70- [ DxfCodeValue ( 71 ) ]
71- public AttachmentPointType AttachmentPoint { get ; set ; } = AttachmentPointType . TopLeft ;
133+ [ DxfCodeValue ( 41 ) ]
134+ public double RectangleWidth { get ; set ; }
72135
73136 /// <summary>
74- /// Drawing direction
137+ /// Specifies the rotation angle for the object.
75138 /// </summary>
76- [ DxfCodeValue ( 72 ) ]
77- public DrawingDirectionType DrawingDirection { get ; set ; } = DrawingDirectionType . LeftToRight ;
78-
79- /// <inheritdoc/>
80- [ DxfCodeValue ( 1 ) ]
81- public string Value { get ; set ; } = string . Empty ;
139+ /// <remarks>
140+ /// The rotation is only valid if the <see cref="Normal"/> is set to the Z axis.
141+ /// </remarks>
142+ /// <value>
143+ /// The rotation angle in radians.
144+ /// </value>
145+ [ DxfCodeValue ( DxfReferenceType . IsAngle | DxfReferenceType . Ignored , 50 ) ]
146+ public double Rotation
147+ {
148+ get
149+ {
150+ return new XY ( this . AlignmentPoint . X , this . AlignmentPoint . Y ) . GetAngle ( ) ;
151+ }
152+ }
82153
83154 /// <inheritdoc/>
84155 [ DxfCodeValue ( DxfReferenceType . Name | DxfReferenceType . Optional , 7 ) ]
@@ -104,18 +175,11 @@ public TextStyle Style
104175 }
105176
106177 /// <inheritdoc/>
107- [ DxfCodeValue ( 11 , 21 , 31 ) ]
108- public XYZ AlignmentPoint { get ; set ; } = XYZ . AxisX ;
178+ public override string SubclassMarker => DxfSubclassMarker . MText ;
109179
110- /// <summary>
111- /// Horizontal width of the characters that make up the mtext entity.
112- /// This value will always be equal to or less than the value of group code 41
113- /// </summary>
114- /// <remarks>
115- /// read-only, ignored if supplied
116- /// </remarks>
117- [ DxfCodeValue ( DxfReferenceType . Ignored , 42 ) ]
118- public double HorizontalWidth { get ; set ; } = 0.9 ;
180+ /// <inheritdoc/>
181+ [ DxfCodeValue ( 1 ) ]
182+ public string Value { get ; set ; } = string . Empty ;
119183
120184 /// <summary>
121185 /// Vertical height of the mtext entity
@@ -126,61 +190,6 @@ public TextStyle Style
126190 [ DxfCodeValue ( DxfReferenceType . Ignored , 43 ) ]
127191 public double VerticalHeight { get ; set ; } = 0.2 ;
128192
129- /// <summary>
130- /// Specifies the rotation angle for the object.
131- /// </summary>
132- /// <value>
133- /// The rotation angle in radians.
134- /// </value>
135- [ DxfCodeValue ( DxfReferenceType . IsAngle , 50 ) ]
136- public double Rotation { get ; set ; } = 0.0 ;
137-
138- /// <summary>
139- /// Mtext line spacing style.
140- /// </summary>
141- [ DxfCodeValue ( 73 ) ]
142- public LineSpacingStyleType LineSpacingStyle { get ; set ; }
143-
144- /// <summary>
145- /// Mtext line spacing factor.
146- /// </summary>
147- /// <remarks>
148- /// Percentage of default (3-on-5) line spacing to be applied.Valid values range from 0.25 to 4.00
149- /// </remarks>
150- [ DxfCodeValue ( 44 ) ]
151- public double LineSpacing { get ; set ; } = 1.0 ;
152-
153- /// <summary>
154- /// Background fill setting
155- /// </summary>
156- [ DxfCodeValue ( 90 ) ]
157- public BackgroundFillFlags BackgroundFillFlags { get ; set ; } = BackgroundFillFlags . None ;
158-
159- /// <summary>
160- /// Determines how much border there is around the text.
161- /// </summary>
162- [ DxfCodeValue ( 45 ) ]
163- public double BackgroundScale { get ; set ; } = 1.5 ;
164-
165- /// <summary>
166- /// Background fill color
167- /// </summary>
168- /// <remarks>
169- /// Color to use for background fill when group code 90 is 1.
170- /// </remarks>
171- [ DxfCodeValue ( 63 , 420 , 430 ) ]
172- public Color BackgroundColor { get ; set ; }
173-
174- /// <summary>
175- /// Transparency of background fill color
176- /// </summary>
177- [ DxfCodeValue ( 441 ) ]
178- public Transparency BackgroundTransparency { get ; set ; }
179-
180- public TextColumn Column { get ; set ; } = new TextColumn ( ) ;
181-
182- public bool IsAnnotative { get ; set ; } = false ;
183-
184193 private double _height = 1.0 ;
185194
186195 private TextStyle _style = TextStyle . Default ;
@@ -280,11 +289,21 @@ public override void ApplyTransform(Transform transform)
280289
281290 this . InsertPoint = newInsert ;
282291 this . Normal = newNormal ;
283- this . Rotation = newRotation ;
284292 this . Height = newHeight ;
285293 this . RectangleWidth *= scale ;
286294 }
287295
296+ /// <inheritdoc/>
297+ public override CadObject Clone ( )
298+ {
299+ MText clone = ( MText ) base . Clone ( ) ;
300+
301+ clone . Style = ( TextStyle ) ( this . Style ? . Clone ( ) ) ;
302+ clone . Column = this . Column ? . Clone ( ) ;
303+
304+ return clone ;
305+ }
306+
288307 /// <inheritdoc/>
289308 public override BoundingBox GetBoundingBox ( )
290309 {
@@ -303,17 +322,6 @@ public string[] GetTextLines()
303322 ) ;
304323 }
305324
306- /// <inheritdoc/>
307- public override CadObject Clone ( )
308- {
309- MText clone = ( MText ) base . Clone ( ) ;
310-
311- clone . Style = ( TextStyle ) ( this . Style ? . Clone ( ) ) ;
312- clone . Column = this . Column ? . Clone ( ) ;
313-
314- return clone ;
315- }
316-
317325 internal override void AssignDocument ( CadDocument doc )
318326 {
319327 base . AssignDocument ( doc ) ;
0 commit comments