wuhuan2080 发表于 2010-6-27 09:29:00

[求助]用选择集提取出来的文本文字的高度

<p>&nbsp; 本来文本文字的高度为3,但是用选择集提取出来后,发现文本文字高度变为了510,请问这是怎么回事?</p>
<p>&nbsp;</p>
<p><font face="Verdana">&nbsp; Set objText = PickedObjs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '将选择集里的PickedObjs实体对象赋值给objText文本对象<br/>&nbsp; objString = objText.textString&nbsp;&nbsp; '得到每个实体对象的文本内容<br/><br/>&nbsp; Height = TextHeight(objString)&nbsp;&nbsp; '利用全局变量得到了字体的高度<br/>&nbsp; </font></p>

wuhuan2080 发表于 2010-6-27 10:25:00

<p>&nbsp;已解决,是因为字体的原因。</p>
<p>&nbsp;原来选择集中的是romans字体,后来生成的是HZ字体,所以高度也相应改变了。</p>

wuhuan2080 发表于 2010-6-28 22:28:00

<p>&nbsp; 今天试了一下,发现问题没有解决。</p>
<p>&nbsp; 图层layer 0是 HZ字体,</p>
<p>&nbsp; 选择集选的文本是romans字体,字体高度为3,但为什么用&nbsp;<font face="Verdana">&nbsp; </font></p>
<p><font face="Verdana">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Height = objText.Height&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp; 或者Height = TextHeight(objString)&nbsp;&nbsp;</font></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 得到的Height都不是3,而是510,很奇怪?(由于CAD是2004,用不了GetTextHeight())</p>
<p>&nbsp;</p>
<p>如下代码供参考:</p>
<p>&nbsp;</p>
<p><font face="Verdana">&nbsp; '过滤组码和过滤值</font></p>
<p><font face="Verdana">&nbsp;&nbsp; Dim FilterType(0) As Integer<br/>&nbsp;&nbsp; Dim FilterData(0) As Variant</font></p>
<p><font face="Verdana">&nbsp;&nbsp; FilterType(0) = 0<br/>&nbsp;&nbsp; FilterData(0) = "Text"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '只选择文本对象</font></p>
<p><font face="Verdana">&nbsp; ssetObj.Select mode, point1, point2, FilterType, FilterData&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '选择矩形窗口内对象(acselectionsetwindow)<br/>&nbsp; 'MsgBox "拾取点的坐标为:(" &amp; point1(0) &amp; "," &amp; point1(1) &amp; "," &amp; point1(2) &amp; ")"<br/>&nbsp; 'MsgBox "拾取点的坐标为:(" &amp; point2(0) &amp; "," &amp; point2(1) &amp; "," &amp; point2(2) &amp; ")"<br/>&nbsp;&nbsp;<br/>&nbsp; '循环每个被选择的实体<br/>&nbsp; Dim PickedObjs As AcadEntity<br/>&nbsp; For Each PickedObjs In ssetObj<br/>&nbsp; PickedObjs.Color = acRed&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '可将所有被选择实体将变为红色</font></p>
<p><font face="Verdana">&nbsp; <br/>&nbsp; Set objText = PickedObjs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '将PickedObjs实体对象赋值给objText文本对象<br/>&nbsp; objString = objText.textString&nbsp;&nbsp; '得到每个实体对象的文本内容<br/>&nbsp; 'MsgBox objString&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '在屏幕上显示文本内容,测试时用<br/>&nbsp; 'Height = objText.GetTextHeight(objString)&nbsp;&nbsp; '返回指定行类型的文字高度。(2005新增)<br/>&nbsp; Height = objText.Height&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '利用全局变量得到了字体的高度<br/>&nbsp; 'Height = TextHeight(objString)&nbsp;&nbsp; '利用全局变量得到了字体的高度<br/>&nbsp; MsgBox Height</font></p>

ctgu123 发表于 2012-6-11 15:21:35

没看懂~~~~~~~~~~~~
页: [1]
查看完整版本: [求助]用选择集提取出来的文本文字的高度