How to parse and convert an AutoCAD MText object to raw text?

I would like to analyze the essence of AutoCAD MText and extract the source text. I see a template in a way to format text. If this has already been decided, then I did not need to reinvent the wheel. I searched the Internet but did not find enough information.

I am looking for any links or links on this topic.

Edit:

For further refinement, we use the ODA (Open Design Alliance) libraries to access DWG files. I am not familiar with this library. Another developer uses a library and extracts information from files, including MText objects. Then I am provided with a file containing the MText text I am looking at. I am viewing text in MText format with which I have access and work with C #.

Questions:

  • I asked another developer if the ODA library provided a tool for extracting raw text. His answer was that it could, however, also cause the entity to be written back to the DWG file. I'm interested in raw text without affecting the original DWG file. Does ODA provide a way to extract the source text without modifying the file?
  • I am interested in any documentation on MText formatting rules, so I can consider writing an analyzer myself, if necessary.
  • Is there anything to convert MText to RTF? I understand that RTF will not fully comply with all formatting rules, but it can provide a satisfactory means of displaying rich text in a WinForms application. Given RTF, I could also get the source code.
+3
4

VB MText. , , , - #.

, AutoCAD.

+3

# .NET, Text MText :

MText mt;
...
string rawText = mt.Text;

, .

+2

AutoCAD AutoCAD, , . :

For DWG, the main options are the Open Design Alliance and AutoCAD RealDWG .

If this does not help, provide more details on what you are trying to do.

+1
source

If you are using C #, try the netDXF library.

I thought the pseudo code should look like this:

DxfDocument dxf = new DxfDocument();
dxf = DxfDocument.Load(openFileDialog1.FileName);//load your file
//This extracts the raw text of your first text obj
dxf.MTexts[0].PlainText;
+1
source

Source: https://habr.com/ru/post/1752565/


All Articles