From 9b11877a4ceea83941077f6bfda103932bb56039 Mon Sep 17 00:00:00 2001 From: musicdie Date: Sat, 10 Sep 2022 09:26:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=8E=B7=E5=8F=96=E5=9D=97?= =?UTF-8?q?=E7=9A=84=E8=A3=81=E5=89=AA=E8=BE=B9=E7=95=8C=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ExtensionMethod/EntityEx.cs | 24 ++++++++++++++++++- tests/TestShared/testblock.cs | 16 ++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/IFoxCAD.Cad.Shared/ExtensionMethod/EntityEx.cs b/src/IFoxCAD.Cad.Shared/ExtensionMethod/EntityEx.cs index 42de3f4..b863abb 100644 --- a/src/IFoxCAD.Cad.Shared/ExtensionMethod/EntityEx.cs +++ b/src/IFoxCAD.Cad.Shared/ExtensionMethod/EntityEx.cs @@ -393,8 +393,30 @@ public static void ClipBlockRef(this BlockReference bref, Point3d pt1, Point3d p dict.SetAt(spatialName, sf); // SetToDictionary(dict, spatialName, sf); } + /// + /// 获取裁剪块参照的裁剪定义 + /// + /// 块参照 + /// 事务 + /// 块裁剪定义 + public static SpatialFilter? ClipedBlockRefPoints(this BlockReference bref, DBTrans? tr = null) + { + tr ??= DBTrans.Top; + var filter = new SpatialFilter(); + if (!bref.ExtensionDictionary.IsOk()) + return null; + var extdict = tr.GetObject(bref.ExtensionDictionary, OpenMode.ForRead); + if (extdict != null && extdict.Contains(filterDictName)) + { + var dict = tr.GetObject(extdict.GetAt(filterDictName), OpenMode.ForRead); + if (dict != null && dict.Contains(spatialName)) + { + filter = tr.GetObject(dict.GetAt(spatialName), OpenMode.ForRead); + } + } + return filter; + } #endregion - #region 属性 /// /// 更新动态块属性值 diff --git a/tests/TestShared/testblock.cs b/tests/TestShared/testblock.cs index 1199e9e..a253505 100644 --- a/tests/TestShared/testblock.cs +++ b/tests/TestShared/testblock.cs @@ -193,7 +193,21 @@ public void Test_ClipBlock() var bref1 = tr.GetObject(id); bref1?.ClipBlockRef(new Point3d(13, 13, 0), new Point3d(17, 17, 0)); } - + [CommandMethod("testclippoints")] + public static void testclippoints() + { + DBTrans tr = new DBTrans(); + PromptEntityOptions peo = new PromptEntityOptions("选择块"); + PromptEntityResult per = tr.Editor!.GetEntity(peo); + if (per.Status != PromptStatus.OK) return; + BlockReference block = tr.GetObject(per.ObjectId)!; + var sfd = block.ClipedBlockRefPoints(); + if (sfd is null) return; + var points = sfd?.Definition.GetPoints(); //裁剪边界 +#if NET45 + var invert = sfd?.Inverted; //是否反向裁剪 +#endif + } /// /// 给用户的测试程序,不知道对错 /// -- Gitee