Skip to content

Commit 26bfa3a

Browse files
committed
Fix on RhinoViewport.Scale extension method.
1 parent 5c5bf18 commit 26bfa3a

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

src/RhinoInside.Revit.External/Extensions/RhinoCommon.cs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,28 @@ public static BoundingBox GetBoundingBox(this Box value, Transform xform)
218218

219219
return new BoundingBox(value.GetCorners(), xform);
220220
}
221+
222+
public static IEnumerable<Plane> ToPlanes(this Box box)
223+
{
224+
var plane = box.Plane;
225+
yield return new Plane(plane.PointAt(0.0, 0.0, box.Z.T0), plane.YAxis, plane.XAxis);
226+
yield return new Plane(plane.PointAt(0.0, box.Y.T0, 0.0), plane.XAxis, plane.ZAxis);
227+
yield return new Plane(plane.PointAt(box.X.T0, 0.0, 0.0), plane.ZAxis, plane.YAxis);
228+
yield return new Plane(plane.PointAt(box.X.T1, 0.0, 0.0), plane.YAxis, plane.ZAxis);
229+
yield return new Plane(plane.PointAt(0.0, box.Y.T1, 0.0), plane.ZAxis, plane.XAxis);
230+
yield return new Plane(plane.PointAt(0.0, 0.0, box.Z.T1), plane.XAxis, plane.YAxis);
231+
}
232+
233+
public static IEnumerable<PlaneSurface> ToSurfaces(this Box box)
234+
{
235+
var plane = box.Plane;
236+
yield return new PlaneSurface(new Plane(plane.PointAt(0.0, 0.0, box.Z.T0), plane.YAxis, plane.XAxis), box.Y, box.X);
237+
yield return new PlaneSurface(new Plane(plane.PointAt(0.0, box.Y.T0, 0.0), plane.XAxis, plane.ZAxis), box.X, box.Z);
238+
yield return new PlaneSurface(new Plane(plane.PointAt(box.X.T0, 0.0, 0.0), plane.ZAxis, plane.YAxis), box.Z, box.Y);
239+
yield return new PlaneSurface(new Plane(plane.PointAt(box.X.T1, 0.0, 0.0), plane.YAxis, plane.ZAxis), box.Y, box.Z);
240+
yield return new PlaneSurface(new Plane(plane.PointAt(0.0, box.Y.T1, 0.0), plane.ZAxis, plane.XAxis), box.Z, box.X);
241+
yield return new PlaneSurface(new Plane(plane.PointAt(0.0, 0.0, box.Z.T1), plane.XAxis, plane.YAxis), box.X, box.Y);
242+
}
221243
}
222244

223245
static class ExtrusionExtension
@@ -1537,11 +1559,13 @@ public static bool Scale(this RhinoViewport viewport, double scaleFactor)
15371559
projection.SetFrustum(left * scaleFactor, right * scaleFactor, bottom * scaleFactor, top * scaleFactor, near * scaleFactor, far * scaleFactor);
15381560
}
15391561

1540-
if (!viewport.SetViewProjection(projection, updateTargetLocation: true))
1562+
if (!viewport.SetViewProjection(projection, updateTargetLocation: false))
15411563
return false;
15421564

15431565
var cplane = viewport.GetConstructionPlane();
1544-
cplane.Plane.Transform(scaleTransform);
1566+
var location = cplane.Plane;
1567+
location.Transform(scaleTransform);
1568+
cplane.Plane = location;
15451569
cplane.GridSpacing *= scaleFactor;
15461570
cplane.SnapSpacing *= scaleFactor;
15471571
viewport.SetConstructionPlane(cplane);

0 commit comments

Comments
 (0)