Display full version of the post: Help for reading MTEXT of DXF file
Can anyone help for reading DXF MTEXT file? When dxf file is opened by notepad, MTEXT block is as following.
MTEXT 5430102{ACAD_XDICTIONARY36078D102}3301F100AcDbEntity 8TEXT100AcDbMText 105.704296354278894 204.855478660749818 300.000000000024344 400.0625 411.0 71 1 72 5 1{\W5.6142; }Starts From \P{\W6.96748; }INDICATOR ABC 73 1 441.01001ACAD1000MTEXTBEGIN1070 731070 11070 4410401.01070 741070 01000MTEXTEND
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:105.704296354278894 204.855478660749818
1{\W5.6142; }Starts From \P{\W6.96748; }INDICATOR ABC
Thank you very much, any help is appreciated.
Harbin
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.
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
Harbin2011-01-25 07:54:41
The \Wnnn is format code for adjusting the width factor.
The \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
It would be tough to figure actual text location after considering justification (71 code), text reference rectangle width (41 code), then paragraph formatting...
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