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

Fixed check for coplanarity on 'Add Wall (Profile)' component. #1057

Merged
merged 1 commit into from
Dec 15, 2023
Merged
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
22 changes: 13 additions & 9 deletions src/RhinoInside.Revit.GH/Components/Element/Wall/ByProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ bool Reuse(ref ARDB.Wall element, IList<Curve> boundaries, Plane plane, Line lin
}

#if REVIT_2021
if (Math.Abs(slantAngle) < element.Document.Application.AngleTolerance)
if (slantAngle != 0.0)
{
element.get_Parameter(ARDB.BuiltInParameter.WALL_CROSS_SECTION).Update(1 /*ARDB.WallCrossSection.Vertical*/);
}
Expand Down Expand Up @@ -195,15 +195,15 @@ loop is null ||

#if !REVIT_2021
if (!plane.ZAxis.IsPerpendicularTo(Vector3d.ZAxis, tol.AngleTolerance))
ThrowArgumentException(nameof(profile), "Profile should be a list of coplanar vertical surfaces.", loop);
ThrowArgumentException(nameof(profile), "Profile should be a list of planar vertical surfaces.", loop);
#endif

loops[index] = loop.Simplify(CurveSimplifyOptions.All, tol.VertexTolerance, tol.AngleTolerance) ?? loop;

using (var properties = AreaMassProperties.Compute(loop, tol.VertexTolerance))
{
if (properties is null)
ThrowArgumentException(nameof(profile), "Failed to compute Boundary Area.", loop);
ThrowArgumentException(nameof(profile), "Failed to compute Profile Area.", loop);

if (properties.Area > maxArea)
{
Expand All @@ -215,7 +215,7 @@ loop is null ||

boundaryPlane = plane;
}
else if (plane.Normal.IsParallelTo(boundaryPlane.Normal) == 0)
else if (plane.Normal.IsParallelTo(boundaryPlane.Normal) == 0 || Math.Abs(plane.DistanceTo(boundaryPlane.Origin)) > GeometryTolerance.Internal.DefaultTolerance)
{
ThrowArgumentException(nameof(profile), "Profile should be a list of coplanar surfaces.", loops);
}
Expand All @@ -234,6 +234,7 @@ loop is null ||
flat.Unitize();
var angle = Vector3d.VectorAngle(flat, normal, line.Direction);
if (angle > Math.PI) angle -= 2.0 * Math.PI;
if (Math.Abs(angle) < document.Application.AngleTolerance) angle = 0.0;

// LocationLine
if (locationLine != ARDB.WallLocationLine.WallCenterline)
Expand Down Expand Up @@ -267,7 +268,7 @@ loop is null ||
if (offsetDist != 0.0)
{
offsetDist *= Revit.ModelUnits / Math.Cos(angle);
var translation = flat * ((wall?.Flipped ?? flipped) ? -offsetDist : offsetDist);
var translation = flat * ((wall?.Flipped is true) ? -offsetDist : offsetDist);

line = new Line(line.From + translation, line.To + translation);
boundaryPlane.Translate(translation);
Expand All @@ -278,8 +279,11 @@ loop is null ||

if (!Reuse(ref wall, loops, boundaryPlane, line, angle, type.Value))
{
for (int l = 0; l < loops.Length; ++l)
loops[l].Rotate(-angle, line.Direction, line.From);
if (angle != 0.0)
{
for (int l = 0; l < loops.Length; ++l)
loops[l].Rotate(-angle, line.Direction, line.From);
}

var boundaries = loops.
SelectMany(x => GeometryEncoder.ToCurveMany(x)).
Expand All @@ -298,7 +302,7 @@ loop is null ||
flat.ToXYZ()
);

// Wait to join at the end of the Transaction
// Delay join at the end of the Transaction
{
ARDB.WallUtils.DisallowWallJoinAtEnd(newWall, 0);
ARDB.WallUtils.DisallowWallJoinAtEnd(newWall, 1);
Expand All @@ -311,7 +315,7 @@ loop is null ||
newWall.get_Parameter(ARDB.BuiltInParameter.STRUCTURAL_ANALYTICAL_MODEL)?.Update(false);

#if REVIT_2021
if (Math.Abs(angle) < newWall.Document.Application.AngleTolerance)
if (angle != 0.0)
{
newWall.get_Parameter(ARDB.BuiltInParameter.WALL_CROSS_SECTION).Update(1 /*ARDB.WallCrossSection.Vertical*/);
}
Expand Down
Loading