Skip to content

Commit

Permalink
Disable transformation from withing Navisworks and apply transformati…
Browse files Browse the repository at this point in the history
…on when importing in Revit
  • Loading branch information
GeorgDangl committed Aug 27, 2024
1 parent 1d37ad1 commit d27a745
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,27 +157,14 @@ private BcfViewpoint GetViewpointFromNavisworksViewpoint(Viewpoint viewpoint,
var elementBoundingBoxDeltaX = maxX - minX;
var elementBoundingBoxDeltaY = maxY - minY;
var elementBoundingBoxDeltaZ = maxZ - minZ;
var clashBoundingBoxMinPoint = new Point3D(centerForBoundingBox.X - 20d.ToInternal(),
centerForBoundingBox.Y - 20d.ToInternal(),
centerForBoundingBox.Z - 20d.ToInternal());
var clashBoundingBoxMaxPoint = new Point3D(centerForBoundingBox.X + 20d.ToInternal(),
centerForBoundingBox.Y + 20d.ToInternal(),
centerForBoundingBox.Z + 20d.ToInternal());
var clashBoundingBoxMinPoint = new Point3D(centerForBoundingBox.X - 1d.ToInternal(),
centerForBoundingBox.Y - 1d.ToInternal(),
centerForBoundingBox.Z - 1d.ToInternal());
var clashBoundingBoxMaxPoint = new Point3D(centerForBoundingBox.X + 1d.ToInternal(),
centerForBoundingBox.Y + 1d.ToInternal(),
centerForBoundingBox.Z + 1d.ToInternal());

commonBoundingBox = new BoundingBox3D(clashBoundingBoxMinPoint, clashBoundingBoxMaxPoint);

try
{
var translation = _doc.Models.FirstOrDefault().Transform.Translation?.Negate();
if (translation != null)
{
commonBoundingBox = commonBoundingBox.Translate(translation);
}
}
catch
{
// Ignoring errors here, that means there's no translation
}
}

var clippingPlanes = TransformBoundingBoxToClippingPlanes(commonBoundingBox);
Expand Down
7 changes: 7 additions & 0 deletions src/IPA.Bcfier.Revit/Services/RevitViewpointDisplayService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,15 @@ private void ApplyClippingPlanes(UIDocument uiDocument, View3D view, BcfViewpoin
if (!boundingBox.Equals(AxisAlignedBoundingBox.Infinite))
{
var revitSectionBox = ToRevitSectionBox(boundingBox);
var transform = _uiDocument.Document.ActiveProjectLocation.GetTransform();
revitSectionBox.Transform = transform;

view.SetSectionBox(revitSectionBox);
view.IsSectionBoxActive = true;

// We want to zoom to the section box, but then also zoom a bit out of it
_uiDocument.GetOpenUIViews().First().ZoomAndCenterRectangle(transform.OfPoint(revitSectionBox.Min), transform.OfPoint(revitSectionBox.Max));
_uiDocument.GetOpenUIViews().First().Zoom(0.7);
}
else
{
Expand Down

0 comments on commit d27a745

Please sign in to comment.