PDA

View Full Version : How to get the real text height from the selection?



wuhuan2080
30th Jun 2010, 03:25 pm
Layer 0 is HZ fonttype,
Text selected from selection is romans ,the real height is 3,but when i use the Methods as follows:
Height = objText.Height
or Height = TextHeight(objString)
The value of Height are not 3,but is 510,so weird?(AutoCAD 2004, cannot use GetTextHeight())

The code as below for reference:

'过滤组*和过滤值
Dim FilterType(0) As Integer
Dim FilterData(0) As Variant
FilterType(0) = 0
FilterData(0) = "Text" '只选择文本对象
ssetObj.Select mode, point1, point2, FilterType, FilterData '选择矩形窗口内对象(acselectionsetwindow)

'循环每个被选择的实体
Dim PickedObjs As AcadEntity
For Each PickedObjs In ssetObj
PickedObjs.Color = acRed '可将所有被选择实体将变为红色

Set objText = PickedObjs '将PickedObjs实体对象赋值给objText文本 象
objString = objText.textString '得到每个实体对象的文本内容
'MsgBox objString '在屏幕上显示文本内容,测试时用
'Height = objText.GetTextHeight(objString) '返回指定行类型的文*高度。(2005新 )
Height = objText.Height '得到*体的高度
'Height = TextHeight(objString) '得到*体的高度
MsgBox Height


If you have a good way, please tell me, thanks advance!

RMS
1st Jul 2010, 04:05 am
can you post the entire code? Also my guess would be that this needs to be converted from some format. I did try to test your example but either my version of .net or Autocad gave me issues.

10west
13th Jul 2010, 10:38 am
That kind of sounds like a drawing units issue, if so you can convert, or set a known unit for realible data;property extraction.

wuhuan2080
17th Jul 2010, 01:43 am
Still understand. But thanks a lot!