From 5b65f9e73de32964e2b4f6b075b49b4337713fee Mon Sep 17 00:00:00 2001 From: Michal Pekacki Date: Fri, 4 Aug 2023 11:43:31 +0200 Subject: [PATCH 1/3] add DrawingArea for FamilyInstance --- Revit_Core_Engine/Query/DrawingArea.cs | 27 +++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/Revit_Core_Engine/Query/DrawingArea.cs b/Revit_Core_Engine/Query/DrawingArea.cs index 366c13fd0..7aa2fd054 100644 --- a/Revit_Core_Engine/Query/DrawingArea.cs +++ b/Revit_Core_Engine/Query/DrawingArea.cs @@ -37,7 +37,32 @@ public static partial class Query /**** Public methods ****/ /***************************************************/ - [Description("Compute the outline of Title Block drawing area.")] + [Description("Returns the drawing area outline of the Title Block instance.")] + [Input("titleBlock", "Title Block to get the drawing area outline from.")] + [Output("outline", "The Title Block's drawing area.")] + public static Outline DrawingArea(this FamilyInstance titleBlock) + { + if (titleBlock == null || !((BuiltInCategory)titleBlock.Category.Id.IntegerValue == Autodesk.Revit.DB.BuiltInCategory.OST_TitleBlocks)) + { + BH.Engine.Base.Compute.RecordWarning($"Title block cannot be null and has to be of Title Block category."); + return null; + } + + Outline drawingArea = titleBlock.Symbol.DrawingArea(); + Transform transform = titleBlock.GetTotalTransform(); + + if (!transform.IsIdentity) + { + drawingArea.MaximumPoint += transform.Origin; + drawingArea.MinimumPoint += transform.Origin; + } + + return drawingArea; + } + + /***************************************************/ + + [Description("Returns the outline of Title Block drawing area.")] [Input("titleBlock", "Title Block symbol to get the drawing area outline from.")] [Output("outline", "The Title Block's drawing area.")] public static Outline DrawingArea(this FamilySymbol titleBlock) From 4c2e54aa5e9f7873a89a134b1aa3ce1cf35fe463 Mon Sep 17 00:00:00 2001 From: Michal Pekacki Date: Fri, 4 Aug 2023 16:11:50 +0200 Subject: [PATCH 2/3] update after @vietle-bh comments --- Revit_Core_Engine/Query/DrawingArea.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Revit_Core_Engine/Query/DrawingArea.cs b/Revit_Core_Engine/Query/DrawingArea.cs index 7aa2fd054..eae5b80b9 100644 --- a/Revit_Core_Engine/Query/DrawingArea.cs +++ b/Revit_Core_Engine/Query/DrawingArea.cs @@ -44,7 +44,7 @@ public static Outline DrawingArea(this FamilyInstance titleBlock) { if (titleBlock == null || !((BuiltInCategory)titleBlock.Category.Id.IntegerValue == Autodesk.Revit.DB.BuiltInCategory.OST_TitleBlocks)) { - BH.Engine.Base.Compute.RecordWarning($"Title block cannot be null and has to be of Title Block category."); + BH.Engine.Base.Compute.RecordWarning($"Title block cannot be null and has to be of the Title Block category."); return null; } @@ -53,8 +53,8 @@ public static Outline DrawingArea(this FamilyInstance titleBlock) if (!transform.IsIdentity) { - drawingArea.MaximumPoint += transform.Origin; - drawingArea.MinimumPoint += transform.Origin; + drawingArea.MaximumPoint = transform.OfPoint(drawingArea.MaximumPoint); + drawingArea.MinimumPoint = transform.OfPoint(drawingArea.MinimumPoint); } return drawingArea; From 78983f2f315f3cea4f36e32eacc2938066837e0b Mon Sep 17 00:00:00 2001 From: Michal Pekacki Date: Mon, 7 Aug 2023 09:24:35 +0200 Subject: [PATCH 3/3] changed RecordWarning to RecordError --- Revit_Core_Engine/Query/DrawingArea.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Revit_Core_Engine/Query/DrawingArea.cs b/Revit_Core_Engine/Query/DrawingArea.cs index eae5b80b9..225f4915f 100644 --- a/Revit_Core_Engine/Query/DrawingArea.cs +++ b/Revit_Core_Engine/Query/DrawingArea.cs @@ -44,7 +44,7 @@ public static Outline DrawingArea(this FamilyInstance titleBlock) { if (titleBlock == null || !((BuiltInCategory)titleBlock.Category.Id.IntegerValue == Autodesk.Revit.DB.BuiltInCategory.OST_TitleBlocks)) { - BH.Engine.Base.Compute.RecordWarning($"Title block cannot be null and has to be of the Title Block category."); + BH.Engine.Base.Compute.RecordError($"Title block cannot be null and has to be of the Title Block category."); return null; }