- 积分
- 981
- 明经币
- 个
- 注册时间
- 2016-9-26
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
本帖最后由 MyNameIsLiLei 于 2022-11-16 09:28 编辑
今天又学到一招,嘻嘻。
-
- [DllImport("accore.dll", CharSet = CharSet.Unicode,CallingConvention = CallingConvention.Cdecl, EntryPoint = "acedTextBox")]
- static extern System.IntPtr acedTextBox(IntPtr rb, double[] point1, double[] point2);
- public Point3d[] GetTextBound(DBText text)
- {
- int mirrored = text.IsMirroredInX ? 2 : 0;
- mirrored |= text.IsMirroredInY ? 4 : 0;
- var rb = new ResultBuffer(
- new TypedValue(1, text.TextString),
- new TypedValue(40, text.Height),
- new TypedValue(41, text.WidthFactor),
- new TypedValue(51, text.Oblique),
- new TypedValue(7, text.TextStyleName),
- new TypedValue(71, mirrored),
- new TypedValue(72, (int)text.HorizontalMode),
- new TypedValue(73, (int)text.VerticalMode));
- var point1 = new double[3];
- var point2 = new double[3];
- acedTextBox(rb.UnmanagedObject, point1, point2);
- var extents = new Extents3d(new Point3d(point1), new Point3d(point2));
- var xform = Matrix3d.Displacement(text.Position.GetAsVector()) *
- Matrix3d.Rotation(text.Rotation, text.Normal, Point3d.Origin) *
- Matrix3d.WorldToPlane(new Plane(Point3d.Origin, text.Normal));
- return new Point3d[]
- {
- extents.MinPoint.TransformBy(xform),
- new Point3d(extents.MaxPoint.X, extents.MinPoint.Y, 0.0).TransformBy(xform),
- extents.MaxPoint.TransformBy(xform),
- new Point3d(extents.MinPoint.X, extents.MaxPoint.Y, 0.0).TransformBy(xform)
- };
- }
效果还不错,嘻嘻。
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
x
|