明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 157|回复: 2

vb.net怎么获取多行文字包围盒

[复制链接]
发表于 2024-5-7 14:28 | 显示全部楼层 |阅读模式
用vb.net怎么获取多行文字包围盒,只是显示的文字部分,不包含编辑框范围的。
发表于 2024-5-7 17:11 | 显示全部楼层
  1.   ''' <summary>
  2.         ''' Gets the WCS points of the mtext bounding box.
  3.         ''' </summary>
  4.         ''' <param name="mtext">Instance of MText the method applies to.</param>
  5.         ''' <returns>The bounding box points in counterclockwise sense.</returns>
  6.         Public Shared Function GetMTextBoxCorners(mtext As MText) As Point3d()
  7.             Dim width As Double = mtext.ActualWidth
  8.             Dim height As Double = mtext.ActualHeight
  9.             Dim point1 As Point3d, point2 As Point3d
  10.             Select Case mtext.Attachment
  11.                 Case AttachmentPoint.TopLeft
  12.                     point1 = New Point3d(0.0, -height, 0.0)
  13.                     point2 = New Point3d(width, 0.0, 0.0)
  14.                     Exit Select
  15.                 Case AttachmentPoint.TopCenter
  16.                     point1 = New Point3d(-width * 0.5, -height, 0.0)
  17.                     point2 = New Point3d(width * 0.5, 0.0, 0.0)
  18.                     Exit Select
  19.                 Case AttachmentPoint.TopRight
  20.                     point1 = New Point3d(-width, -height, 0.0)
  21.                     point2 = New Point3d(0.0, 0.0, 0.0)
  22.                     Exit Select
  23.                 Case AttachmentPoint.MiddleLeft
  24.                     point1 = New Point3d(0.0, -height * 0.5, 0.0)
  25.                     point2 = New Point3d(width, height * 0.5, 0.0)
  26.                     Exit Select
  27.                 Case AttachmentPoint.MiddleCenter
  28.                     point1 = New Point3d(-width * 0.5, -height * 0.5, 0.0)
  29.                     point2 = New Point3d(width * 0.5, height * 0.5, 0.0)
  30.                     Exit Select
  31.                 Case AttachmentPoint.MiddleRight
  32.                     point1 = New Point3d(-width, -height * 0.5, 0.0)
  33.                     point2 = New Point3d(0.0, height * 0.5, 0.0)
  34.                     Exit Select
  35.                 Case AttachmentPoint.BottomLeft
  36.                     point1 = New Point3d(0.0, 0.0, 0.0)
  37.                     point2 = New Point3d(width, height, 0.0)
  38.                     Exit Select
  39.                 Case AttachmentPoint.BottomCenter
  40.                     point1 = New Point3d(-width * 0.5, 0.0, 0.0)
  41.                     point2 = New Point3d(width * 0.5, height, 0.0)
  42.                     Exit Select
  43.                 Case AttachmentPoint.BottomRight
  44.                     point1 = New Point3d(-width, 0.0, 0.0)
  45.                     point2 = New Point3d(0.0, height, 0.0)
  46.                     Exit Select
  47.             End Select
  48.             Dim xform As Matrix3d = Matrix3d.Displacement(mtext.Location.GetAsVector()) * Matrix3d.Rotation(mtext.Rotation, mtext.Normal, Point3d.Origin) * Matrix3d.PlaneToWorld(New Plane(Point3d.Origin, mtext.Normal))
  49.             Return New Point3d() {point1.TransformBy(xform), New Point3d(point2.X, point1.Y, 0.0).TransformBy(xform), point2.TransformBy(xform), New Point3d(point1.X, point2.Y, 0.0).TransformBy(xform)}
  50.         End Function
 楼主| 发表于 2024-5-8 08:26 | 显示全部楼层
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-20 00:44 , Processed in 0.211036 second(s), 22 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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