diff --git a/src/RhinoInside.Revit.External/DB/Extensions/GeometryObject.cs b/src/RhinoInside.Revit.External/DB/Extensions/GeometryObject.cs index 4c3025852..93bb59afe 100644 --- a/src/RhinoInside.Revit.External/DB/Extensions/GeometryObject.cs +++ b/src/RhinoInside.Revit.External/DB/Extensions/GeometryObject.cs @@ -669,6 +669,7 @@ public static BoundingBoxXYZ GetBoundingBox(this GeometryObject geometry, Transf else { var bbox = element.GetTransformed(coordSystem.Inverse).GetBoundingBox(); + if (bbox.IsNegative()) bbox = BoundingBoxXYZExtension.Empty; bbox.Transform = coordSystem; return bbox; } @@ -690,6 +691,7 @@ public static BoundingBoxXYZ GetBoundingBox(this GeometryObject geometry, Transf else { var bbox = instance.GetSymbolGeometry(coordSystem.Inverse * instance.Transform).GetBoundingBox(); + if (bbox.IsNegative()) bbox = BoundingBoxXYZExtension.Empty; bbox.Transform = coordSystem; return bbox; } @@ -697,6 +699,7 @@ public static BoundingBoxXYZ GetBoundingBox(this GeometryObject geometry, Transf else { var bbox = instance.SymbolGeometry.GetBoundingBox(); + if (bbox.IsNegative()) bbox = BoundingBoxXYZExtension.Empty; bbox.Transform = instance.Transform; return bbox; } @@ -744,11 +747,11 @@ public static BoundingBoxXYZ GetBoundingBox(this GeometryObject geometry, Transf { if (!solid.Faces.IsEmpty) { + var bbox = BoundingBoxXYZExtension.Empty; if (coordSystem is object) { if (accurateSolid) { - var bbox = BoundingBoxXYZExtension.Empty; bbox.Transform = coordSystem; foreach (Face face in solid.Faces) @@ -761,7 +764,10 @@ public static BoundingBoxXYZ GetBoundingBox(this GeometryObject geometry, Transf { using (var transformed = SolidUtils.CreateTransformed(solid, coordSystem.Inverse)) { - var (min, max, transform, bounds) = transformed.GetBoundingBox(); + bbox = transformed.GetBoundingBox(); + if (bbox.IsNegative()) bbox = BoundingBoxXYZExtension.Empty; + + var (min, max, transform, bounds) = bbox; var (minX, minY, minZ) = transform.OfPoint(min); var (maxX, maxY, maxZ) = transform.OfPoint(max); @@ -774,7 +780,10 @@ public static BoundingBoxXYZ GetBoundingBox(this GeometryObject geometry, Transf } } } - return solid.GetBoundingBox(); + + bbox = solid.GetBoundingBox(); + if (bbox.IsNegative()) bbox = BoundingBoxXYZExtension.Empty; + return bbox; } } break; diff --git a/src/RhinoInside.Revit/AssemblyResolver.cs b/src/RhinoInside.Revit/AssemblyResolver.cs index 9fb023e26..dcb758c13 100644 --- a/src/RhinoInside.Revit/AssemblyResolver.cs +++ b/src/RhinoInside.Revit/AssemblyResolver.cs @@ -544,7 +544,8 @@ static Assembly GetRequestingAssembly() int f = 0; for (; f < frames.Length; ++f) { - var frameAssembly = frames[f].GetMethod().DeclaringType.Assembly; + var method = frames[f].GetMethod(); + var frameAssembly = method.DeclaringType?.Assembly ?? method.Module?.Assembly; if (frameAssembly != callingAssembly) break; } @@ -552,7 +553,8 @@ static Assembly GetRequestingAssembly() // Skip mscorlib for (; f < frames.Length; ++f) { - var frameAssembly = frames[f].GetMethod().DeclaringType.Assembly; + var method = frames[f].GetMethod(); + var frameAssembly = method.DeclaringType?.Assembly ?? method.Module?.Assembly; if (frameAssembly != typeof(object).Assembly) return frameAssembly; }