How does one parse and convert AutoCAD MText entity to raw text?

*爱你&永不变心* 提交于 2019-12-05 18:53:05

This Forum thread includes a VB program to strip the control characters from the MText. The code indicates what should be done to strip each control character, so it should be straightforward to write something similar in C#.

Additionally, the documentation of the format codes is available in the AutoCAD documentation.

If you are using C# and the .NET interface, the Text property of the MText object provides the raw text:

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

If you want the formatting as well, the solution is different.

Knyphe

If you are parsing an AutoCAD file without AutoCAD, you need to specify what file type you are parsing. However, this question is basically a subset of the following questions:

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

If this doesn't help, please provide more details as to exactly what you are trying to do.

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

I thought pseudo code should be 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;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!