如何解析 AutoCAD MText 实体并将其转换为原始文本? [英] How does one parse and convert AutoCAD MText entity to raw text?

查看:45
本文介绍了如何解析 AutoCAD MText 实体并将其转换为原始文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想解析 AutoCAD 的 MText 实体并提取原始文本.我看到文本格式的模式.如果这已经解决了,那么我就不需要重新发明轮子了.我在网上搜索过,但没有找到足够的信息.

I would like to parse AutoCAD's MText entity and extract the raw text. I see a pattern in the way the text is formatted. If this has already been solved, then I would not need to reinvent the wheel. I have searched online, but have not found sufficient information.

我正在搜索有关此主题的任何链接或参考资料.

I am searching for any links or references on this subject.

为了进一步澄清,我们使用 ODA(开放设计联盟)库来访问 DWG 文件.我不熟悉这个图书馆.另一位开发人员正在使用该库并从包括多行文字实体在内的文件中提取信息.然后我得到了一个包含多行文字文本的文件,这就是我正在查看的内容.我正在查看 MText 格式的文本,我可以在 C# 中访问并使用它.

To further clarify, we are using the ODA (Open Design Aliance) libraries to access the DWG files. I am not familiar with this library. Another developer is using the library and extracting information from the files including MText entities. I am then provided with a file containing the MText text, which is what I am looking at. I am looking at the MText formatted text, which I have access to and am working with in C#.

问题:

  1. 我询问其他开发人员 ODA 库是否提供了一种提取未格式化原始文本的方法.他的回答是,这可能会导致实体被写回 DWG 文件.我对原始文本感兴趣而不影响原始 DWG 文件.ODA 是否提供了一种无需更改文件即可提取原始文本的方法?
  2. 我对有关 MText 格式规则的任何文档感兴趣,以便在必要时考虑自己编写解析器.
  3. 有什么可以将 MText 转换为 RTF 的吗?我意识到 RTF 不能完全满足所有格式规则,但这可以提供一种令人满意的方式在 WinForms 应用程序中显示格式化文本.鉴于 RTF,我还可以获得原始文本.

推荐答案

This 论坛主题 包括一个 VB 程序,用于从多行文字中去除控制字符.代码指示了应该如何去除每个控制字符,因此在 C# 中编写类似的代码应该很简单.

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#.

此外,格式代码的文档可在 AutoCAD 文档.

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

这篇关于如何解析 AutoCAD MText 实体并将其转换为原始文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆