diff --git a/BHoM_Engine/Query/Geometry.cs b/BHoM_Engine/Query/Geometry.cs index d7abbea56..707a60be7 100644 --- a/BHoM_Engine/Query/Geometry.cs +++ b/BHoM_Engine/Query/Geometry.cs @@ -46,6 +46,12 @@ public static IGeometry IGeometry(this IBHoMObject obj) public static IGeometry Geometry(this CustomObject obj) { + if(obj == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot query the geometry of a null custom object."); + return null; + } + List geometries = new List(); foreach (object item in obj.CustomData.Values) diff --git a/BHoM_Engine/Query/Geometry3D.cs b/BHoM_Engine/Query/Geometry3D.cs index d5afa6005..5a64e3c77 100644 --- a/BHoM_Engine/Query/Geometry3D.cs +++ b/BHoM_Engine/Query/Geometry3D.cs @@ -53,6 +53,12 @@ public static IGeometry IGeometry3D(this IObject obj) public static IGeometry Geometry3D(this CustomObject obj) { + if(obj == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot query the 3D Geometry of a null custom object."); + return null; + } + List geometries = new List(); foreach (object item in obj.CustomData.Values) diff --git a/BHoM_Engine/Query/GetAllFragments.cs b/BHoM_Engine/Query/GetAllFragments.cs index 02f81c440..2745e5cc6 100644 --- a/BHoM_Engine/Query/GetAllFragments.cs +++ b/BHoM_Engine/Query/GetAllFragments.cs @@ -43,6 +43,9 @@ public static partial class Query [Output("fragmentList", "A deep copy of the fragments is returned for immutability.")] public static List GetAllFragments(this IBHoMObject iBHoMObject, Type parentType = null) { + if (iBHoMObject == null) + return new List(); + List fragments = new List(); if (parentType == null) diff --git a/BHoM_Engine/Query/Hash.cs b/BHoM_Engine/Query/Hash.cs index 1b23bd586..d44af0ca2 100644 --- a/BHoM_Engine/Query/Hash.cs +++ b/BHoM_Engine/Query/Hash.cs @@ -51,6 +51,12 @@ public static partial class Query [Input("hashFromFragment", "If true, if the object is a BHoMObject storing a HashFragment, retrieve the hash from it instead of computing the hash.")] public static string Hash(this IObject iObj, ComparisonConfig comparisonConfig = null, bool hashFromFragment = false) { + if(iObj == null) + { + BH.Engine.Reflection.Compute.RecordError("Cannot query the hash of a null object."); + return ""; + } + if (hashFromFragment && iObj is IBHoMObject) { // Instead of computing the Hash, first tryGet the hash in HashFragment diff --git a/BHoM_Engine/Query/UniquenessRestrictions.cs b/BHoM_Engine/Query/UniquenessRestrictions.cs index 91421f2f5..88e0911d0 100644 --- a/BHoM_Engine/Query/UniquenessRestrictions.cs +++ b/BHoM_Engine/Query/UniquenessRestrictions.cs @@ -41,6 +41,9 @@ public static partial class Query [Input("type", "The type of object you want to apply the fragment to.")] public static List UniquenessRestrictions(this Type type) { + if (type == null) + return new List(); + // Do not cover value types if (type.IsValueType) return new List();