乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 46|回复: 3

[已解决]还是关于DBtext的问题,不解

[复制链接]

14

主题

43

帖子

3

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
99
发表于 2011-11-26 13:05:00 | 显示全部楼层 |阅读模式
代码如下:
  1. Transaction tr = Tools.Database.TransactionManager.StartTransaction();
  2.     Polyline curLine = tr.GetObject(polyid, OpenMode.ForRead) as Polyline;
  3.    
  4.     DBText mText = new DBText();
  5.     mText.SetDatabaseDefaults();
  6.     mText.TextString = "面积:"+Math.Round(curLine.Area, 3).ToString();
  7.     mText.Position = curLine.GeometricExtents.MaxPoint;
  8.     ObjectId mid = Tools.AddToCurrentSpace(mText);
  9.     mText = tr.GetObject(mid, OpenMode.ForWrite) as DBText;
  10.     mText.VerticalMode = TextVerticalMode.TextVerticalMid;  //问题就出在这两句
  11.     mText.HorizontalMode = TextHorizontalMode.TextCenter;
  12.     mText.Height = 5.0;
  13.    
  14.     mText.Position = curLine.GeometricExtents.MaxPoint;
  15.    
  16.    
  17.     tr.Commit();

当指定text的对齐方式,加入数据库后,文字的position总是在原点,试了好多办法都行不通。
请高手指点一下
自己找到解决办法了。。晕,刚发的贴。
  1. mText.VerticalMode = TextVerticalMode.TextVerticalMid;
  2.         mText.HorizontalMode = TextHorizontalMode.TextCenter;
  3.         mText.AlignmentPoint = curLine.GeometricExtents.MaxPoint;  //这句是关键
回复

使用道具 举报

14

主题

43

帖子

3

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
99
发表于 2011-11-26 13:19:00 | 显示全部楼层
经多次测试,得出如下结论,供大家参考:
DBText对象当设置VerticalMode   HorizontalMode后,文本的Position属性已无用。重新赋值也没有用,此时需指定AlignmentPoint来决定文本的位置!
回复

使用道具 举报

13

主题

84

帖子

6

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
136
发表于 2011-11-26 22:50:00 | 显示全部楼层
你的理解有问题。
If vertical mode is set to any value other than .TextBase, then the text object's alignment point is used to determine the text's position. The position point is recalculated based on the text string and the alignment point's value. If vertical mode is .TextBase, then the position point is used to determine the text's position. The alignment point is recalculated based on the text string and the position point's value.
回复

使用道具 举报

14

主题

43

帖子

3

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
99
发表于 2011-11-27 20:00:00 | 显示全部楼层
楼上能否写明白点,我的英语确实太差了些,看不太明白。只明白前面几句:
如果垂直方式被设置值,文本对象的对齐点被用来确定文本的位置
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-15 21:05 , Processed in 5.722912 second(s), 61 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表