Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix on GeometryObject.GetBoundingBox extension method. #1207

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/RhinoInside.Revit.External/DB/Extensions/GeometryObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -690,13 +691,15 @@ 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;
}
}
else
{
var bbox = instance.SymbolGeometry.GetBoundingBox();
if (bbox.IsNegative()) bbox = BoundingBoxXYZExtension.Empty;
bbox.Transform = instance.Transform;
return bbox;
}
Expand Down Expand Up @@ -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)
Expand All @@ -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);

Expand All @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions src/RhinoInside.Revit/AssemblyResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -544,15 +544,17 @@ 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;
}

// 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;
}
Expand Down
Loading