在 AutoCAD 中使用文本样式创建线条/几何图形
我正在使用 ObjectARX .Net API 在 AutoCAD 中工作。有没有办法使用线条/曲线/折线创建文本,或将现有文本对象分解为线条/等?我希望能够基于现有的 AutoCAD 文本样式生成线条。
编辑:我能够在 此处 找到 TxtExp 命令的源代码。然而它是用 AutoCAD 自己的 Lisp 语言编写的,我无法理解它。
编辑:查看 TxtExp 的源代码,它只是将文本导出为 WMF 文件,然后将其导入。不幸的是,没有公开用于导入和导出 WMF 文件的 .NET API,因此我无法使用该方法来执行此操作。
I'm working in AutoCAD using the ObjectARX .Net API. Is there a way to either create text using lines/curves/polylines, or explode an existing text object into lines/ect? Prefereable I would like to be able to generate linework based on an exsiting AutoCAD text style.
Edit: I was able to find the source for the TxtExp command here . However its in AutoCADs own Lisp language, and I can't make heads or tails of it.
Edit: Looking at the source of TxtExp, it just exports the text as a WMF file and then imports it. Unfourtunatly, there is not .NET API exposed for doing the import and export of WMF files, so I can't use that method to do it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过使用
AcGiWorldGeometry
和AcGiWorldDraw
?我没有使用过 ObjectArx,但我使用过 DwgDirect(现在称为 Teigha for DWG - 可从 http://www.opendesign 获取。 com/),其中部分内容应该是 ObjectArx 的克隆。通过简要阅读 ObjectArx 文档,我可以看出,您似乎可以实现自己的AcGiWorldGeometry
对象并将其传递给文本的worldDraw
方法。AcGiGeometry
指定了许多相当于回调函数的内容。当几何图形将自身“绘制”到“世界绘制”对象中时,将调用各种回调函数。按照我使用 DwgDirect 的方式,您可以重写某些回调,具体取决于您希望如何接收结果。本质上,您将实现一个对象来捕获几何图形(在您的情况下为文本)的“矢量化”或“爆炸”。在 DwgDirect 中,在最简单的情况下,我只能实现“折线”功能。任何元素在“渲染”时最终都会分解为一条或多条折线。在我的项目中,例如,如果我不想获得“圆”,那么我对“圆”回调的实现就是简单地调用基本实现(或者我根本不会覆盖该回调 - 我不记得了)。这将导致下一个级别的“简化”发生,并且我的“多边形”回调将被调用。然后我可以将圆捕获为“描边”多边形。
还有 AcGiTextEngine 类可能会有所帮助。请注意,其方法被标记为“仅供内部使用”。话虽如此,有一种曲面细分方法(重载)似乎提供了抚摸/爆炸/曲面细分功能。从签名来看,您似乎给了它一个文本样式、一些文本(字符串)和一个“PolylineCallback”,我猜它会根据参数调用适当的回调。
很抱歉,我没有为您提供好的代码示例,但我使用 DwgDirect 的项目是很久以前的事了,现在我无法轻松访问该代码。我没有直接使用 ObjectArx,所以我也没有该代码的任何示例。
回顾我的答案并仔细查看文档(我在这里找到的:http://docs.autodesk.com/ACDMAC/2011/ENU/ObjectARX%20Reference/index.html ),看来我一直在查看 C++ 文档。我不知道 .NET 接口中是否存在等效功能。
[编辑]
根据我在这里找到的帮助文件(http://www.codeproject.com/KB/dotnet/arxref.aspx),看起来.NET版本中确实有类似的类,可能允许您尝试执行我上面描述的操作。从 WorldGeometry 和 WorldDraw 开始,您也许能够得到您想要的结果。
祝你好运!
Have you tried using
AcGiWorldGeometry
andAcGiWorldDraw
? I have not used ObjectArx, but I have used DwgDirect (now called Teigha for DWG - available from http://www.opendesign.com/), parts of which are supposed be sort of a clone of ObjectArx. From what I can tell by briefly reading the ObjectArx docs, it seems that you might be able to implement your ownAcGiWorldGeometry
object and pass it to theworldDraw
method of your text.AcGiGeometry
specifies many what amount to callback functions. When the geometry "draws" itself into the "world draw" object, the various callback functions will be called.In the way that I have used DwgDirect, you could override some of the callbacks, depending on how you want to receive the results. In essence, you would be implementing an object to captured the "vectorization" or "exploding" of the geometry (text in your case). In DwgDirect, in the simplest case, I could implement only the "polyline" function. Any element, when "rendered" would ultimately break down to one or more polylines. In my project, if I did not want to get a "circle" for example, my implementation of the "circle" callback would be to simply call the base implementation (or I would not override that callback at all - I can't remember). That would cause the next level of "simplification" to happen and my "polygon" callback would called. I could then capture the circle as a "stroked" polygon.
There is also the AcGiTextEngine class that might help. Note that its methods are marked "for internal use only". Having said that, there is a tesellate method (overloaded) that appears to provide stroking/explosing/tesellation capability. From the signature, it looks like you give it a text style, some text (string), and a "PolylineCallback" and, I guess, it will call the callback as appropriate for the parameters.
I'm sorry that I don't have a good code example for you but the project where I used DwgDirect was a long time ago and I don't have easy access to that code now. I have not used ObjectArx directly, so I also don't have any examples of that code.
Having looked back over my answer and looking closer at the documentation (that I found here: http://docs.autodesk.com/ACDMAC/2011/ENU/ObjectARX%20Reference/index.html ), it looks like I have been looking at the C++ docs. I don't know if equivalent functionality exists in the .NET interface.
[EDIT]
According to the help file that I found here (http://www.codeproject.com/KB/dotnet/arxref.aspx), it does look there are similar classes in the .NET version that might allow you to try to do what I described above. Start with WorldGeometry and WorldDraw and you might be able to get the result that you want.
Good luck!
我只是在 Autodesk 讨论页面上进行了快速搜索,因为我什至不确定是否可以分解文本。我发现这个发布并在 AutoCad 2010 中进行了尝试。它将文本分解为一堆 2D 折线。
我在此处广告中进行了搜索 .Net 讨论,但没有搜索到找不到任何东西。也许您可以使用 ActiveDocument.SendCommand() 来执行它。
我知道这并不能回答你的问题,但也许它会让你感动。玩得开心!
I just did a quick search on the Autodesk Discussion page as I wasn't even sure if one could explode text. I found this post and tried it in AutoCad 2010. It exploded the text into a buch of 2D Polylines.
I performed a search here ad the in the .Net Discussions and didn't find anything. Maybe you could use
ActiveDocument.SendCommand()
to execute it.I know this doesn't answer your question, but maybe it will get you moving. Have fun!