From d8dbb917e7a228df32812bd591c6fc0157d70a92 Mon Sep 17 00:00:00 2001 From: dosymep Date: Mon, 5 May 2025 12:03:42 +0300 Subject: [PATCH 1/2] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=20=D0=BF=D0=BE=D0=BB=D1=83?= =?UTF-8?q?=D1=87=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BE=D0=B1=D1=8A=D0=B5=D0=BC?= =?UTF-8?q?=D0=B0=20=D1=81=D0=BE=D0=BB=D0=B8=D0=B4=D0=B0,=20=D0=B2=D0=BE?= =?UTF-8?q?=D0=B7=D0=B2=D1=80=D0=B0=D1=89=D0=B0=D0=B5=D1=82=20null=20?= =?UTF-8?q?=D0=B5=D1=81=D0=BB=D0=B8=20=D0=BE=D0=B1=D1=8A=D0=B5=D0=BC=20?= =?UTF-8?q?=D0=BD=D0=B5=20=D1=83=D0=B4=D0=B0=D0=BB=D0=BE=D1=81=D1=8C=20?= =?UTF-8?q?=D0=B2=D1=8B=D1=87=D0=B8=D1=81=D0=BB=D0=B8=D1=82=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dosymep.Revit/Geometry/SolidExtensions.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/dosymep.Revit/Geometry/SolidExtensions.cs b/src/dosymep.Revit/Geometry/SolidExtensions.cs index 2ea4016..1290614 100644 --- a/src/dosymep.Revit/Geometry/SolidExtensions.cs +++ b/src/dosymep.Revit/Geometry/SolidExtensions.cs @@ -1,8 +1,11 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using Autodesk.Revit.DB; +using InvalidOperationException = Autodesk.Revit.Exceptions.InvalidOperationException; + namespace dosymep.Revit.Geometry { /// /// Расширения для @@ -39,5 +42,18 @@ public static IList CreateUnitedSolids(IList solids) { result.Add(union); return result; } + + /// + /// Возвращает объем . + /// + /// , для которого вычисляется объем. + /// Возвращает объем , или null, если объем не может быть определен. + public static double? GetVolumeOrDefault(this Solid solid) { + try { + return solid?.Volume; + } catch(InvalidOperationException) { + return null; + } + } } } \ No newline at end of file From b7daf6c464f85732d8378d7f5b276d6cb25439c1 Mon Sep 17 00:00:00 2001 From: dosymep Date: Mon, 5 May 2025 12:10:02 +0300 Subject: [PATCH 2/2] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=20=D0=B7=D0=BD=D0=B0=D1=87=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BF?= =?UTF-8?q?=D0=BE=20=D1=83=D0=BC=D0=BE=D0=BB=D1=87=D0=B0=D0=BD=D0=B8=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dosymep.Revit/Geometry/SolidExtensions.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/dosymep.Revit/Geometry/SolidExtensions.cs b/src/dosymep.Revit/Geometry/SolidExtensions.cs index 1290614..a717b8a 100644 --- a/src/dosymep.Revit/Geometry/SolidExtensions.cs +++ b/src/dosymep.Revit/Geometry/SolidExtensions.cs @@ -44,15 +44,16 @@ public static IList CreateUnitedSolids(IList solids) { } /// - /// Возвращает объем . + /// Возвращает объем или значение по умолчанию, если объем не может быть определен. /// /// , для которого вычисляется объем. - /// Возвращает объем , или null, если объем не может быть определен. - public static double? GetVolumeOrDefault(this Solid solid) { + /// Значение по умолчанию, возвращаемое в случае, если объем не может быть определен. + /// Возвращает объем , или значение по умолчанию, если объем не может быть определен. + public static double? GetVolumeOrDefault(this Solid solid, double? defaultValue = null) { try { - return solid?.Volume; + return solid?.Volume ?? defaultValue; } catch(InvalidOperationException) { - return null; + return defaultValue; } } }