开发者

Create Linework/Geometry Using Text Style in AutoCAD

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'开发者_StackOverflowt 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.


Have you tried using AcGiWorldGeometry and AcGiWorldDraw? 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 own AcGiWorldGeometry object and pass it to the worldDraw 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!


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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜