Print Page | Close Window

Help for reading MTEXT of DXF file

Printed From: CAD Forum
Category: EN
Forum Name: CAD - general
Forum Description: General discussion about CAD, formats, standards, management, licensing, networking, harware, other CAD applications
URL: https://www.cadforum.cz/forum_en/forum_posts.asp?TID=5178
Printed Date: 01.Oct.2026 at 18:00


Topic: Help for reading MTEXT of DXF file
Posted By: Harbin
Subject: Help for reading MTEXT of DXF file
Date Posted: 24.Jan.2011 at 19:57

Can anyone help for reading DXF MTEXT file? When dxf file is opened by notepad, MTEXT block is as following.

MTEXT
  5
430
102
{ACAD_XDICTIONARY
360
78D
102
}
330
1F
100
AcDbEntity
  8
TEXT
100
AcDbMText
 10
5.704296354278894
 20
4.855478660749818
 30
0.000000000024344
 40
0.0625
 41
1.0
 71
     1
 72
     5
  1
{\W5.6142;  }Starts From \P{\W6.96748; }INDICATOR ABC
 73
     1
 44
1.0
1001
ACAD
1000
MTEXTBEGIN
1070
    73
1070
     1
1070
    44
1040
1.0
1070
    74
1070
     0
1000
MTEXTEND
 
Here is the issue:
group code 71, 1 means this MTEXT is aligned at Top Left.
But actually this MTEXT is aligned at Center. When I open this file by AutoCAD, the contents of property start with "\pxqc;". I think it means "align center" and these special characters are not shown when openning by notepad. So, {\W5.6142;  } must be related to "\pxqc;".
 
Can anyone help to find the actual MTEXT starting location by using:
10
5.704296354278894
 20
4.855478660749818

 1
{\W5.6142;  }Starts From \P{\W6.96748; }INDICATOR ABC
Thank you very much, any help is appreciated.
 
Harbin



Replies:
Posted By: CarlB
Date Posted: 24.Jan.2011 at 22:53
Well 10 & 11 are supposed to be X & Y values of insertion point.
Value of 1 for code 71 is supposed to be Top left justification. So I don't see anything to explain why you found different justification..
 
 
Here are some mtext formatting codes that may expalin some things:
Format code        Purpose                                                                
\0...\o            Turns overline on and off
\L...\l           Turns underline on and off
\~                        Inserts a nonbreaking space
\\                          Inserts a backslash
\{...\}               Inserts an opening and closing brace
\File name;    Changes to the specified font file
\Hvalue;            Changes to the text height specified in drawing units
\Hvaluex;          Changes the text height to a multiple of the current text height
\S...^...;       Stacks the subsequent text at the \, #, or ^ symbol
\Tvalue;            Adjusts the space between characters, from.75 to 4 times
\Qangle;            Changes obliquing angle
\Wvalue;            Changes width factor to produce wide text
\A                          Sets the alignment value; valid values: 0, 1, 2 (bottom, center, top)

Note: Use curly braces ({ }) to apply a format change only to the text within the braces. You can nest braces up to eight levels deep.


Posted By: Harbin
Date Posted: 25.Jan.2011 at 07:52

Hi CarlB,

 

Thank you for your reply. Actually I am C# programmer and know only a little about AutoCAD.

Just like you said: Code 71 =1 means Top Left justification. But, do you know what {\w5.6142;} means?

 

When I open that DXF file in AutoCAD and check the property of that particular MTEXT part:

Contents : \pxqc;Starts From\P and so on.

Justification: Top Left   ---- this matches code 71=1

 

When I click the particular MTEXT ( for modification purpose???, I can modify the MTEXT contents), I found “Align Center ” is selected in the pop-up window(text editing window?). I tried to select “Align left” in that pop-up window. The contents of MTEXT property changed to “\pxql;Starts From\P and so on.”

 

When I open that DXF by notepad, code 1 contents start with {\w5.6142;}. So, I said {\w5.6142;} was related to \pxqc; . Do you have any idea about it?

 MTEXT top left coordinate can be retreived from code 10 and 20. Since the actual justification is top center, the value {\w5.6142;} should be used to move text contents to right a little bit. I tried to add 5.6142 to x coordinate. It was incorrect.
 
Please forgive me my unprofessional terminology. I hope you can understand what I am trying to explain. Maybe I need to provide some screen shots.
 
TIA.
 
Harbin

 



Posted By: CarlB
Date Posted: 25.Jan.2011 at 08:28
The file://%5C%5CWnnn" rel="nofollow - \Wnnn is format code for adjusting the width factor.
The file://%5C%5Cpxnnn" rel="nofollow - \pxnnn  is format code for different paragraph formatting, such as centered, right/left justify, etc.
See this site for some examples:
http://caddiesoftware.com/caddiesoftware/faq/31-general/161-change-the-format-of-text-using-special-characters.html" rel="nofollow - http://caddiesoftware.com/caddiesoftware/faq/31-general/161-change-the-format-of-text-using-special-characters.html
 
It would be tough to figure actual text location after considering justification (71 code), text reference rectangle width (41 code), then paragraph formatting...


Posted By: Harbin
Date Posted: 25.Jan.2011 at 17:03
Thanks anyway.
 
Looks like it is hard to calculate the acutual TEXT starting coordinates.
{\w5.6142;  }: insert two spaces with width value 5.6142 ? But the reference rectangle width is only 1.0.
 
Here is my solution:
If contents start with "{\w", change the justification of this TEXT to (Top/Middle/Bottom) Center.
 
CarlB, do you think it is going to work?
Thanks again,
 
Harbin



Print Page | Close Window