/// <summary>
/// возвращаем реальный габарит MText
/// </summary>
/// <param name="mTextId"></param>
/// <returns></returns>
private Extents3d? MtextRealExtents(MText mText)
{
if (mText != null)
{
Point3d point = mText.Location;
Plane plane = new Plane(point, mText.Normal);
Vector3d vx = plane.Normal.GetPerpendicularVector().TransformBy(Matrix3d.Rotation(mText.Rotation, plane.Normal, point)).GetNormal(); ;
Vector3d vy = vx.TransformBy(Matrix3d.Rotation(Math.PI / 2, plane.Normal, point)).GetNormal();
double h = mText.ActualHeight;
double w = mText.ActualWidth;
//получаем нижний левый угол текста
switch (mText.Attachment)
{
case AttachmentPoint.TopLeft:
point = point - vy * h;
break;
case AttachmentPoint.MiddleCenter:
point = point - vy * h / 2 - vx * w / 2;
break;
case AttachmentPoint.TopCenter:
point = point - vy * h - vx * w / 2;
break;
case AttachmentPoint.TopRight:
point = point - vy * h - vx * w;
break;
case AttachmentPoint.MiddleLeft:
point = point - vy * h / 2;
break;
case AttachmentPoint.MiddleRight:
point = point - vy * h / 2 - vx * w;
break;
case AttachmentPoint.BottomLeft:
break;
case AttachmentPoint.BottomCenter:
point = point - vx * w / 2;
break;
case AttachmentPoint.BottomRight:
point = point - vx * w;
break;
}
//получаем точки 4 углов в wcs
//достаточно перспективные данные, дают 4 реальных угла текста а не прямоугольник области
List<Point3d> points = new List<Point3d>
{
point,
point + vx * w + vy * h,
point + vx * w,
point + vy * h,
};
//получаем все координаты точек
List<double> x = new List<double>();
List<double> y = new List<double>();
foreach (Point3d p in points)
{
x.Add(p.X);
y.Add(p.Y);
}
//возвращаем новые габариты
return new Extents3d(new Point3d(x.Min(), y.Min(), 0).Project(plane, Vector3d.ZAxis), new Point3d(x.Max(), y.Max(), 0).Project(plane, Vector3d.ZAxis));
}
return null;
}