(1)AcDbText实体转换成AcDbMtext
There is no API to convert an AcDbText entity to an AcDbMText entity. Also asmentioned in the help files the AcDbMText::setFromTextEntity() function is deprecated.
So, we will have to query all the AcDbText's properties and map them to the
AcDbMtext entity ourselves.
There are two properties that we need to take special care of while mapping.
Firstly, the AcDbText has more justifications possible than the AcDbMText, so
we need to map all the AcDbText justifications to the AcDbMText justifications
such that justification is as close as possible to AcDbText's justification.
The only case where the AcDbMText entity does not match the AcDbText entity
entirely is when the text entity has the "Fit" option. The Mtext does not have
this option.
Secondly, we need to calculate the location(insertion) point for the Mtext object.
The AcDbText as two control points, namely position and alignment point. Depending
upon the vertical and horizontal modes either the position or the alignment
point is used as insertion point. It is a bit confusing to get the required
insertion point for the Mtext from these points. Instead we can create the Mtext
entity at origin and then get the maximum point of the bounding box of both
the Mtext and Text. Using these maximum points we can move the Mtext entity
such that it appears exactly over the text entity.
The attached VC++ ARX project creates an AcDbMText entity which copies all properties
from a selected AcDbText entity. Also, the test drawing "test.dwg" in the attachment
contains the AcDbText entities which can be used to test for all the text justifications.
The text string indicates what justification is used on the text entity.
**** Hidden Message *****
多谢老大,沙发 看看ARX代码有多难懂.... 学习学习! pMText->mirrorInX(pText->isMirroredInX());
pMText->mirrorInY(pText->isMirroredInY());
pMText->setOblique(pText->oblique());
pMText->setThickness(pText->thickness());
上述方法在2004以上版本已经没有了,没找到替代方法!
牢固 发表于 2014-12-5 16:19
pMText->mirrorInX(pText->isMirroredInX());
pMText->mirrorInY(pText->isMirroredInY());
pMText->setO ...
2004以上mtext还有这些属性吗?
thickness是不是统一到Entity了 牢固 发表于 2014-12-5 16:19
pMText->mirrorInX(pText->isMirroredInX());
pMText->mirrorInY(pText->isMirroredInY());
pMText->setO ...
没有就先注释掉吧。这代码都是早期版本下写的,对齐设置等还是值得推荐的。
XDSoft 发表于 2014-12-5 18:50
没有就先注释掉吧。这代码都是早期版本下写的,对齐设置等还是值得推荐的。
现在都是格式符控制,没有整体属性了吧 XDSoft 发表于 2014-12-5 18:50
没有就先注释掉吧。这代码都是早期版本下写的,对齐设置等还是值得推荐的。
Direction属性好像是控制文字方向?
牢固 发表于 2014-12-5 19:20
Direction属性好像是控制文字方向?
从上往下或者从下往上,图中的箭头。
学习一下!! st788796 发表于 2014-12-5 18:57
现在都是格式符控制,没有整体属性了吧
你说的整体属性是指什么?
XDSoft 发表于 2014-12-5 19:53
从上往下或者从下往上,图中的箭头。
你这个是FlowDirection属性!Direction方向值就是祖玛11的值,
st788796 发表于 2014-12-5 18:57
现在都是格式符控制,没有整体属性了吧
对于有对齐点设置的TEXT实体,比如MC对齐,用这个代码转换后的MTEXT和普通的MTEXT里面设置对齐有些不同,看图。
下图是普通TEXT实体用(xdrx_text->mtext e)转换后编辑成两行的样子,MTEXT实体有对齐的夹点。
双击进入UI编辑时候,中间有两箭头。
而普通的MTEXT,进入里面设置的对齐方式表现图下图,没有上图中间的两箭头符号。
也没对齐的夹点
牢固 发表于 2014-12-5 20:02
你这个是FlowDirection属性!Direction方向值就是祖玛11的值,
对,是 X 轴方向
AcGeVector3d direction() const;
Description
Returns an AcGeVector3d (in WCS) representing the X axis ("horizontal") for the text. This direction vector is used to determine the text flow direction.