File: mtext.rst

package info (click to toggle)
ezdxf 1.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 104,528 kB
  • sloc: python: 182,341; makefile: 116; lisp: 20; ansic: 4
file content (244 lines) | stat: -rw-r--r-- 7,881 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
MText
=====

.. module:: ezdxf.entities
    :noindex:

The MTEXT entity (`DXF Reference`_) fits a multiline text in a specified width but can
extend vertically to an indefinite length. You can format individual words or characters
within the :class:`MText`.

.. seealso::

    :ref:`tut_mtext`

======================== ==========================================
Subclass of              :class:`ezdxf.entities.DXFGraphic`
DXF type                 ``'MTEXT'``
Factory function         :meth:`ezdxf.layouts.BaseLayout.add_mtext`
Inherited DXF attributes :ref:`Common graphical DXF attributes`
Required DXF version     DXF R2000 (``'AC1015'``)
======================== ==========================================

.. _DXF Reference: https://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-5E5DB93B-F8D3-4433-ADF7-E92E250D2BAB

.. class:: MText

    .. attribute:: dxf.insert

        Insertion point (3D Point in :ref:`OCS`)

    .. attribute:: dxf.char_height

        Initial text height (float); default=1.0

    .. attribute:: dxf.width

        Reference text width (float), forces text wrapping at given width.

    .. attribute:: dxf.attachment_point

        Constants defined in :mod:`ezdxf.lldxf.const`:

        ============================== =======
        MText.dxf.attachment_point     Value
        ============================== =======
        MTEXT_TOP_LEFT                 1
        MTEXT_TOP_CENTER               2
        MTEXT_TOP_RIGHT                3
        MTEXT_MIDDLE_LEFT              4
        MTEXT_MIDDLE_CENTER            5
        MTEXT_MIDDLE_RIGHT             6
        MTEXT_BOTTOM_LEFT              7
        MTEXT_BOTTOM_CENTER            8
        MTEXT_BOTTOM_RIGHT             9
        ============================== =======

    .. attribute:: dxf.flow_direction

        Constants defined in :mod:`ezdxf.const`:

        ============================== ======= ===========
        MText.dxf.flow_direction       Value   Description
        ============================== ======= ===========
        MTEXT_LEFT_TO_RIGHT            1       left to right
        MTEXT_TOP_TO_BOTTOM            3       top to bottom
        MTEXT_BY_STYLE                 5       by style (the flow direction is inherited from the associated text style)
        ============================== ======= ===========


    .. attribute:: dxf.style

        Text style (string); default is "STANDARD"

    .. attribute:: dxf.text_direction

        X-axis direction vector in :ref:`WCS` (3D Point); default value is (1, 0, 0);
        if :attr:`dxf.rotation` and :attr:`dxf.text_direction` are present,
        :attr:`dxf.text_direction` wins.

    .. attribute:: dxf.rotation

        Text rotation in degrees (float); default is 0

    .. attribute:: dxf.line_spacing_style

        Line spacing style (int), see table below

    .. attribute:: dxf.line_spacing_factor

        Percentage of default (3-on-5) line spacing to be applied. Valid values range
        from 0.25 to 4.00 (float).

        Constants defined in :mod:`ezdxf.lldxf.const`:

        ============================== ======= ===========
        MText.dxf.line_spacing_style   Value   Description
        ============================== ======= ===========
        MTEXT_AT_LEAST                 1       taller characters will override
        MTEXT_EXACT                    2       taller characters will not override
        ============================== ======= ===========

    .. attribute:: dxf.bg_fill

        Defines the background fill type. (DXF R2007)

        ============================== ======= ===========
        MText.dxf.bg_fill              Value   Description
        ============================== ======= ===========
        MTEXT_BG_OFF                   0       no background color
        MTEXT_BG_COLOR                 1       use specified color
        MTEXT_BG_WINDOW_COLOR          2       use window color (?)
        MTEXT_BG_CANVAS_COLOR          3       use canvas background color
        ============================== ======= ===========

    .. attribute:: dxf.box_fill_scale

        Determines how much border there is around the text.  (DXF R2007)

        Requires that the attributes `bg_fill`, `bg_fill_color` are present otherwise
        AutoCAD complains.

        It's recommended to use :meth:`set_bg_color`

    .. attribute:: dxf.bg_fill_color

        Background fill color as :ref:`ACI` (DXF R2007)

        It's recommended to use :meth:`set_bg_color`

    .. attribute:: dxf.bg_fill_true_color

        Background fill color as true color value (DXF R2007), also the
        :attr:`dxf.bg_fill_color` attribute must be present otherwise AutoCAD complains.

        It's recommended to use :meth:`set_bg_color`

    .. attribute:: dxf.bg_fill_color_name

        Background fill color as name string (?) (DXF R2007), also the
        :attr:`dxf.bg_fill_color` attribute must be present otherwise AutoCAD complains.

        It's recommended to use :meth:`set_bg_color`

    .. attribute:: dxf.transparency

        Transparency of background fill color (DXF R2007), not supported by AutoCAD nor
        BricsCAD.

    .. attribute:: text

        MTEXT content as string (read/write).

        The line ending character ``\n`` will be replaced by the MTEXT line ending
        ``\P`` at DXF export, but **not** vice versa the ``\P`` character by ``\n`` at
        DXF file loading, therefore loaded MTEXT entities always use the ``\P``
        character for line endings.

    .. automethod:: set_location

    .. automethod:: get_rotation

    .. automethod:: set_rotation

    .. automethod:: get_text_direction

    .. automethod:: set_bg_color

    .. automethod:: __iadd__

    .. automethod:: append

    .. automethod:: plain_text

    .. automethod:: all_columns_plain_text

    .. automethod:: all_columns_raw_content

    .. automethod:: transform

    .. automethod:: ucs

.. _mtext_inline_codes:

MText Inline Codes
------------------

======= ===========
Code    Description
======= ===========
\\L     Start underline
\\l     Stop underline
\\O	    Start overline
\\o	    Stop overline
\\K	    Start strike-through
\\k	    Stop strike-through
\\P	    New paragraph (new line)
\\p     Paragraphs properties: indentation, alignment, tabulator stops
\\X	    Paragraph wrap on the dimension line (only in dimensions)
\\Q	    Slanting (oblique) text by angle - e.g. \\Q30;
\\H     Text height - e.g. relative \\H3x; absolut \\H3;
\\W	    Text width - e.g. relative \\W0.8x; absolut \\W0.8;
\\T     Tracking, character spacing - e.g. relative \\T0.5x; absolut \\T2;
\\F	    Font selection e.g. \\Fgdt;o - GDT-tolerance
\\S     Stacking, fractions e.g. \\SA^ B; space after "^" is required to avoid
        caret decoding, \\SX/Y; \\S1#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

\\~     Non breaking space
{}      Braces - define the text area influenced by the code, codes and braces
        can be nested up to 8 levels deep
\\      Escape character - e.g. \\{ = "{"
======= ===========

Convenient constants defined in MTextEditor:
--------------------------------------------

=================== ===========
Constant            Description
=================== ===========
UNDERLINE_START     start underline text
UNDERLINE_STOP      stop underline text
OVERSTRIKE_START    start overline
OVERSTRIKE_STOP     stop overline
STRIKE_START        start strike through
STRIKE_STOP         stop strike through
GROUP_START         start of group
GROUP_END           end of group
NEW_LINE            start in new line
NBSP                none breaking space
=================== ===========