明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3566|回复: 9

[图元] [求助]如何求出DBText单行文本的长度?? 已解决

[复制链接]
发表于 2009-10-19 11:05 | 显示全部楼层 |阅读模式
本帖最后由 作者 于 2009-10-19 15:25:18 编辑

查了很多资料,说是用  DBText.GeometricExtents.MaxPoint.X - DBText.GeometricExtents.MinPoint.X 的很多,不过这种方法得出的值貌似不是DBText的长度。 那么如何才能正确得出DBText中文本的长度呢?还有 如何得出 DBText中文本的宽度比例?

发表于 2009-10-19 11:08 | 显示全部楼层
 楼主| 发表于 2009-10-19 13:12 | 显示全部楼层
本帖最后由 作者 于 2009-10-19 15:24:33 编辑

比如 我用的DBText的 MSITStore:C:\Documents%20and%20Settings\Administrator\桌面\arxmgd.chm::/Autodesk_AutoCAD_DatabaseServices_DBText_WidthFactor.html">WidthFactor =1.0 ,而直到DBText中字符串的个数也就是string的长度len,DBText的Height属性值是height,如何求出DBText的长度呢,直接用 double length = MSITStore:C:\Documents%20and%20Settings\Administrator\桌面\arxmgd.chm::/Autodesk_AutoCAD_DatabaseServices_DBText_WidthFactor.html">WidthFactor * len * height吗??

已解决 果然是 double length = MSITStore:C:\Documents%20and%20Settings\Administrator\桌面\arxmgd.chm::/Autodesk_AutoCAD_DatabaseServices_DBText_WidthFactor.html">WidthFactor * len * height

发表于 2009-10-19 16:29 | 显示全部楼层

字体样式不一样,DBText的长度也是不一样的

发表于 2009-10-27 16:35 | 显示全部楼层
怎样获取不同样式的字体长度?
发表于 2009-10-27 20:11 | 显示全部楼层

二楼不是有解决方法么

发表于 2010-1-5 16:11 | 显示全部楼层
double length =  MSITStore:C:\Documents%20and%20Settings\Administrator\桌面\arxmgd.chm::/Autodesk_AutoCAD_DatabaseServices_DBText_WidthFactor.html">WidthFactor  * len * height    这样不行的,如果是字母,数子汉字等混在一起,这样就不能测出确切的长度,取文字的范围点应该更精确一些
发表于 2010-1-5 23:01 | 显示全部楼层

那就

DBText.GeometricExtents.MaxPoint.X - DBText.GeometricExtents.MinPoint.X

发表于 2010-1-17 19:26 | 显示全部楼层

问楼上版主:若文字是斜的的呢?呵呵!(Sorry!之前没有看到版主在二楼的回复)

DBText 用 DBText.GeometricExtents.MaxPoint.X - DBText.GeometricExtents.MinPoint.X应该没有问题,

但若是MText好象就问题多多!

发表于 2012-11-15 13:53 | 显示全部楼层
Math.Sqrt(Math.Pow((DBText.GeometricExtents.MaxPoint-DBText.GeometricExtents.MinPoint).Length,2)-Math.Pow(DBText.Height,2))
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-4-28 08:59 , Processed in 1.221785 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表