找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 1521|回复: 5

[BUG报告] XdRx_Mtext_Box

[复制链接]

已领礼包: 859个

财富等级: 财运亨通

发表于 2015-1-29 07:38:33 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
本帖最后由 csharp 于 2015-1-29 08:03 编辑

API  中这个函数仅考虑了 AttachmentPoint   kTopLeft = 1 情况,未考虑其他 8 种情况,当对齐方式不为 1 时,求出的 Box 的左下角点是在 MText 的 AcDbMText::location 而非实际位置,下面是用 C# 写的 MText 真实 BOX

注意: 仅适用于 WCS 平行平面的 MText

  1.        public static Point3d [] GetMtextBox(MText mText)
  2.         {
  3.             var pt = mText.Location;
  4.             var angle = mText.Rotation;
  5.             var width = mText.ActualWidth;
  6.             var height = mText.ActualHeight;
  7.             var result=new Point3d[4];
  8.             var axis = new Vector3d(0, 0, 1);
  9.             switch (mText.Attachment)
  10.             {
  11.                 case AttachmentPoint.TopLeft:
  12.                     result [0] = pt + new Vector3d(0, -height, 0).RotateBy( angle,axis);
  13.                     result[1] = pt + new Vector3d(width, -height, 0).RotateBy( angle,axis);
  14.                     result[2] = pt + new Vector3d(width, 0, 0).RotateBy(angle, axis);
  15.                     result[3] = pt;
  16.                     break;
  17.                 case AttachmentPoint.TopCenter:
  18.                     result[0] = pt + new Vector3d(-width/2, -height, 0).RotateBy(angle, axis);
  19.                     result[1] = pt + new Vector3d(width/2, -height, 0).RotateBy(angle, axis);
  20.                     result[2] = pt + new Vector3d(width/2, 0, 0).RotateBy(angle, axis);
  21.                     result[3] = pt + new Vector3d(-width/2, 0, 0).RotateBy(angle, axis);
  22.                     break;
  23.                 case AttachmentPoint.TopRight:
  24.                     result[0] = pt + new Vector3d(-width, -height, 0.0).RotateBy(angle, axis);
  25.                     result[1] = pt + new Vector3d(0, -height, 0).RotateBy(angle, axis);
  26.                     result[2] = pt;
  27.                     result[3] = pt + new Vector3d(-width, 0, 0).RotateBy(angle, axis);
  28.                     break;
  29.                 case AttachmentPoint.MiddleLeft:
  30.                     result[0] = pt + new Vector3d(0, -height/2, 0).RotateBy(angle, axis);
  31.                     result[1] = pt + new Vector3d(width, -height/2, 0).RotateBy(angle, axis);
  32.                     result[2] = pt + new Vector3d(width, height/2, 0).RotateBy(angle, axis);
  33.                     result[3] = pt + new Vector3d(0, height/2, 0).RotateBy(angle, axis);
  34.                     break;
  35.                 case AttachmentPoint.MiddleCenter:
  36.                     result[0] = pt + new Vector3d(-width/2, -height/2, 0).RotateBy(angle, axis);
  37.                     result[1] = pt + new Vector3d(width/2, -height/2, 0).RotateBy(angle, axis);
  38.                     result[2] = pt + new Vector3d(width/2, height/2, 0).RotateBy(angle, axis);
  39.                     result[3] = pt + new Vector3d(-width/2, height/2, 0).RotateBy(angle, axis);
  40.                     break;
  41.                 case AttachmentPoint.MiddleRight:
  42.                     result[0] = pt + new Vector3d(-width, -height/2, 0).RotateBy(angle, axis);
  43.                     result[1] = pt + new Vector3d(0, -height/2, 0).RotateBy(angle, axis);
  44.                     result[2] = pt + new Vector3d(0, height/2, 0).RotateBy(angle, axis);
  45.                     result[3] = pt + new Vector3d(-width, height/2, 0).RotateBy(angle, axis);
  46.                     break;
  47.                 case AttachmentPoint.BottomLeft:
  48.                     result[0] = pt;
  49.                     result[1] = pt + new Vector3d(width, 0, 0).RotateBy(angle, axis);
  50.                     result[2] = pt + new Vector3d(width, height, 0).RotateBy(angle, axis);
  51.                     result[3] = pt + new Vector3d(0, height, 0).RotateBy(angle, axis);
  52.                     break;
  53.                 case AttachmentPoint.BottomCenter:
  54.                     result[0] = pt + new Vector3d(-width/2, 0, 0).RotateBy(angle, axis);
  55.                     result[1] = pt + new Vector3d(width/2, 0, 0).RotateBy(angle, axis);
  56.                     result[2] = pt + new Vector3d(width/2, height, 0).RotateBy(angle, axis);
  57.                     result[3] = pt + new Vector3d(-width/2, height, 0).RotateBy(angle, axis);
  58.                     break;
  59.                 case AttachmentPoint.BottomRight:
  60.                     result[0] = pt + new Vector3d(-width, 0, 0).RotateBy(angle, axis);
  61.                     result[1] = pt;
  62.                     result[2] = pt + new Vector3d(0, height, 0).RotateBy(angle, axis);
  63.                     result[3] = pt + new Vector3d(-width, height, 0).RotateBy(angle, axis);
  64.                     break;
  65.                 default:
  66.                     break;
  67.             }
  68.             return result;
  69.         }
复制代码
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!

已领礼包: 40个

财富等级: 招财进宝

发表于 2015-1-29 23:41:35 | 显示全部楼层
你试试 xdrx_entity_box 看看结果是什么。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 40个

财富等级: 招财进宝

发表于 2015-1-29 23:42:30 | 显示全部楼层
或者  (xdrx_getpropertyvalue ent "boundingbox")

点评

统统不对  详情 回复 发表于 2015-1-30 08:57
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 859个

财富等级: 财运亨通

 楼主| 发表于 2015-1-30 08:57:46 | 显示全部楼层
newer 发表于 2015-1-29 23:42
或者  (xdrx_getpropertyvalue ent "boundingbox")

统统不对   
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2015-10-18 12:04:31 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2015-10-20 23:49:16 | 显示全部楼层
支持一下..不错
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

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

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-5-21 11:48 , Processed in 0.383302 second(s), 42 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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